private void TurnOn(IEntity source) { if (On) { return; } On = true; AuraUpdateInstructionsQueue.Enqueue(new AuraUpdateInstruction(Instruction.AddAll), 1); }
private void TurnOff(IEntity source) { if (!On) { return; } On = false; if (source.Game.Logging) { source.Game.Log(LogLevel.DEBUG, BlockType.TRIGGER, "SwitchingAura.TurnOff", $"{source} triggers {_offTrigger}. {Owner}'s aura is now turned off for this turn."); } AuraUpdateInstructionsQueue.Enqueue(new AuraUpdateInstruction(Instruction.RemoveAll), 0); }
public override void Update() { bool addAllProcessed = false; while (AuraUpdateInstructionsQueue.Count > 0) { AuraUpdateInstruction inst = AuraUpdateInstructionsQueue.Dequeue(); switch (inst.Instruction) { case Instruction.RemoveAll: RemoveAll(); return; case Instruction.AddAll: addAllProcessed = true; AddAll(); break; case Instruction.Add: if (addAllProcessed) { break; } Apply(inst.Src); AppliedEntityIdCollection.Add(inst.Src.Id); break; case Instruction.Remove: if (!AppliedEntityIdCollection.Remove(inst.Src.Id)) { break; } DeApply(inst.Src); break; } } }