How to Destroy GameObjects from PrefabInstallers after Installation? - zenject

I might have misunderstood the PrefabInstaller but I want to use it to let the LevelDesigner configure settings. However, Zenject seems not to destroy the PrefabInstallers afert installation and so I am left over with unecessary Installer-GameObjects (xyzInstaller (Clone)). How do I properly clean them up?

Related

How to immobilize a mob in a script?

To fix the Gruul script, I need to immobilize the boss in an already existing event and remove that flag in another.
However, I can't find a way to prevent Gruul from chasing his target.
I tried comparing it to permanently snared bosses like Ragnaros and C'thun without finding a flag which fits my intentions.
Any hint, how to temporarily prevent movement is appreciated.
I am working on https://github.com/azerothcore/azerothcore-wotlk/blob/master/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp
I want to add code which immobilizes Gruul while casting "Ground Slam" until he casts "Shatter" to make it blizzlike.
In detail
https://github.com/azerothcore/azerothcore-wotlk/blob/389227e4f7ea75292549a36d4f288cc2467d1078/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp#L119
this event needs to immobilize him and this one https://github.com/azerothcore/azerothcore-wotlk/blob/389227e4f7ea75292549a36d4f288cc2467d1078/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp#L126
should make him move again.
I've been looking through the Wiki, trying various flags to no avail. Thankfully i got some replies on discord which suggested UNIT_FLAG_PACIFIED (which prevents attacks but does not immobilize from my tests) and UNIT_FLAG_STUNNED (which prevents the "Ground Slam" cast from being finished but does not prevent Gruuls movement either.
To achieve the above, i used this syntax, adding the 4 lines setting/removing flags:
case EVENT_GROUND_SLAM:
Talk(SAY_SLAM);
me->CastSpell(me, SPELL_GROUND_SLAM, false);
events.DelayEvents(8001);
events.ScheduleEvent(EVENT_GROUND_SLAM, 60000);
events.ScheduleEvent(EVENT_SHATTER, 8000);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
break;
case EVENT_SHATTER:
Talk(SAY_SHATTER);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
me->CastSpell(me, SPELL_SHATTER, false);
break;
This code makes the boss (here: Gruul) stay in place.
me->SetControlled(true, UNIT_STATE_ROOT);
Setting the first argument to false removes the root.
Thanks to Yehonal on discord for pointing this out.

QUndoStack remove specific command

How can I remove a specific command from a QUndoStack?
This command can be given by its index or pointer.
If you are using Qt 5.9, the QUndoStack::command(int index) and QUndoCommand::setObsolete(bool obsolete) functions are probably what you are looking for. The relevant docs from the QUndoStack::redo() command provide the explanation for how an obsoleted command is handled:
If QUndoCommand::isObsolete() returns true for the current command, then the command will be deleted from the stack. Additionally, if the clean index is greater than or equal to the current command index, then the clean index is reset.
That's the thing about stacks - you only work on top of the stack. You can push and you can pop. You don't remove stuff from the middle of the stack.
In an undo-redo scenario this is even more important, as the order of commands must be diligently preserved for the whole thing to work. Otherwise you will break it.
Which is why it is called an "undo stack" and not "reverse arbitrary action whatchamacallit".
There is QUndoStack::setIndex(int idx) which will undo all commands until the provided index. But you cannot really remove only a specific command. You need to undo all commands until you reach and remove the one you want.
As #dtech has pointed out, it does not make sense to undo a command which is not at the most recently pushed command (i.e., the command at top of the stack).
It does, however, make sense to undo the most recently pushed command.
And QUndoStack provides a very convenient way to do this: QUndoStack::undo().
But, this does not delete the command, as it will still be available through QUndoStack::push(...). To truly delete the command, it must be marked obsolete before undoing it:
auto* cmd = const_cast<QUndoCommand*>(undo_stack.command(undo_stack.count()-1));
cmd->undo(); // must be called explicitly
cmd->setObsolete(true);
undo_stack.undo();
It requires a const_cast, so I'd call it a hack. But for me, it works.

FluentValidation exception, abstractValidator cs not found

I am doing UnitTest,when ever debug the method it throws exception saying AbstractValidator.cs not found, ValidationTestExtension.cs not found and i re-install the FluentValidation, fluentValidation.mvc5 but couldn't resolve,..what should i do?
Two things,
first make sure that in your controller where youre making the call for that model you have
if (ModelState.IsValid)
If that doesnt fix it, go to your solution, right click > properties, in properties check the 'Debug Source Files' and add the files to the Do not look for these source files:' section.

C++ access violation: TImage.Picture is null

I recently made some minor changes within my c++-builder-project-settings to distribute a built application, however now some kind of initialisation seems to be missing.
Before I was using this (worked properly):
TPngImage *img=new TPngImage;
img->LoadFromFile(pfad);
Image1->Picture->Assign(img);
However, suddenly I get the error: access-violation... access to 0x0000000.
I checked and noticed that Image1->Picture is Null.
Image1 is of course a TImage-Object added per designer.
I'm using embarcaderos XE2 16 c++-Builder.
Is there a setting for this or could you tell me, what I have to do?
I thought of Image1->Picture=new TPicture(); already, but that is also Null...
It seems that it was my settings...
Somehow I messed some setting up.
I exported the settings of a new project, copied my include-paths, overwrote the settings with the exported one and inserted the includes.
Now everything works again.

How do I run some code after every build in scons?

I'm looking for a way to register somthing like an end-build callback in scons. For example, I'm doing something like this right now:
def print_build_summary():
failures = SCons.Script.GetBuildFailures()
notifyExe = 'notify-send '
if len(failures) > 0:
notifyExe = notifyExe + ' --urgency=critical Build Failed'
else:
notifyExe = notifyExe + ' --urgency=normal Build Succeed'
os.system(notifyExe)
atexit.register(print_build_summary)
This only works in non-interactive mode. I'd like to be able to pop up something like this at the end of every build, specifically, when running multiple 'build' commands in an interactive scons session.
The only suggestions I've found, looking around, seem to be to use the dependency system or the AddPostAction call to glom this on. It doesn't seem quite right to me to do it that way, since it's not really a dependency (it's not even really a part of the build, strictly speaking) - it's just a static bit of code that needs to be run at the end of every build.
Thanks!
I don't think there's anything wrong with using the dependency system to resolve this. This is how I normally do it:
def finish( target, source, env ):
raise Exception( 'DO IT' )
finish_command = Command( 'finish', [], finish )
Depends( finish_command, DEFAULT_TARGETS )
Default( finish_command )
This creates a command that depends on the default targets for it's execution (so you know it'll always run last - see DEFAULT_TARGETS in scons manual). Hope this helps.
Ive been looking into this and havent found that SCons offers anything that would help. This seems like quite a usefull feature, maybe the SCons developers are watching these threads and will take the suggestion...
I looked at the source code and figured out how to do it. I'll try to suggest this change to the SCons developers on scons.org.
If you're interested, the file is engine/SCons/Script/Main.py, and the function is _build_targets(). At the end of this funcion, you would simply need to add a call to a user supplied callback. Of course this solution would not be very useful if you build on several different machines in your network, since you would have to port the change everywhere its needed, but if you're only building on one machine, then maybe you could make the change until/if SCons officially provides a solution.
Let me know if you need help implementing the change, and I'll see what I can do.
Another option would be to wrap the call to SCons, and have the wrapper script perform the desired actions, but that wouldnt help in SCons interactive mode.
Hope this helps,
Brady
EDIT:
I create a feature request for this: http://scons.tigris.org/issues/show_bug.cgi?id=2834