public void Modify(KeyCode keyCode, HotkeyModifier modifier) { appliedKey = keyCode; appliedModifier = modifier; EventHandler.ExecuteEvent(this, GameEvents.HotkeyBindingChanged); }
private void OnMapLoaded(string map, NetworkingMode mode) { Assert.AreEqual(mode, NetworkingMode.Server); worldManager = new WorldServerManager(false); EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.WorldInitialized, worldManager); }
private void Launch() { ExecutionState = SpellExecutionState.Processing; Caster.SpellHistory.StartCooldown(SpellInfo); SelectImplicitTargets(); for (int effectIndex = 0; effectIndex < SpellInfo.Effects.Count; effectIndex++) { SpellInfo.Effects[effectIndex].Handle(this, effectIndex, Caster, SpellEffectHandleMode.Launch); } ImplicitTargets.HandleLaunch(out bool isDelayed, out SpellProcessingToken processingToken); EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.ServerSpellLaunch, Caster, ExplicitTargets.Source, SpellInfo, processingToken); DropModifierCharges(); if (!isDelayed) { foreach (var targetInfo in ImplicitTargets.Entries) { ProcessTarget(targetInfo); } Finish(); } }
private void Launch() { ExecutionState = SpellExecutionState.Processing; Caster.SpellHistory.HandleCooldown(SpellInfo); SelectImplicitTargets(); for (int effectIndex = 0; effectIndex < SpellInfo.Effects.Count; effectIndex++) { SpellInfo.Effects[effectIndex].Handle(this, effectIndex, Caster, SpellEffectHandleMode.Launch); } ImplicitTargets.HandleLaunch(out bool isDelayed, out SpellProcessingToken processingToken); if (!spellValue.CastFlags.HasTargetFlag(SpellCastFlags.DontReportCastSuccess)) { EventHandler.ExecuteEvent(GameEvents.ServerSpellLaunch, Caster, SpellInfo, processingToken); } DropModifierCharges(); ConsumePowers(); Caster.Spells.ApplySpellTriggers(SpellTriggerFlags.DoneSpellCast, Caster, this); if (!isDelayed) { foreach (var targetInfo in ImplicitTargets.Entries) { ProcessTarget(targetInfo); } Finish(); } }
private void ProcessTarget(SpellTargetEntry targetEntry) { if (targetEntry.Processed) { return; } targetEntry.Processed = true; if (targetEntry.Target.IsAlive != targetEntry.Alive) { return; } Unit caster = OriginalCaster ?? Caster; if (caster == null) { return; } SpellMissType missType = targetEntry.MissCondition; EffectDamage = 0; EffectHealing = 0; Unit hitTarget = targetEntry.Target; if (missType == SpellMissType.Reflect && targetEntry.ReflectResult == SpellMissType.None) { hitTarget = Caster; } missType = ProcessSpellHit(hitTarget); if (missType != SpellMissType.None) { EffectDamage = 0; } EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.ServerSpellHit, Caster, hitTarget, SpellInfo, missType); if (EffectHealing > 0) { caster.Spells.HealBySpell(new SpellHealInfo(caster, targetEntry.Target, SpellInfo, (uint)EffectHealing, targetEntry.Crit)); } else if (EffectDamage > 0) { caster.Spells.DamageBySpell(new SpellDamageInfo(caster, targetEntry.Target, SpellInfo, (uint)EffectDamage, targetEntry.Crit, SpellDamageType.Direct), this); } if (missType == SpellMissType.None) { for (int effectIndex = 0; effectIndex < SpellInfo.Effects.Count; effectIndex++) { SpellInfo.Effects[effectIndex].Handle(this, effectIndex, hitTarget, SpellEffectHandleMode.HitFinal); } } }
public override void BoltShutdownBegin(AddCallback registerDoneCallback, UdpConnectionDisconnectReason disconnectReason) { base.BoltShutdownBegin(registerDoneCallback, disconnectReason); if (world != null && world.HasServerLogic) { EventHandler.ExecuteEvent(GameEvents.DisconnectedFromMaster); } }
public override void SceneLoadLocalDone(string map) { base.SceneLoadLocalDone(map); if (BoltNetwork.IsConnected) { EventHandler.ExecuteEvent(GameEvents.GameMapLoaded, map, networkingMode); } }
public override void OnEvent(SpellDamageDoneEvent spellDamageEvent) { base.OnEvent(spellDamageEvent); if (LocalPlayer == null || !World.UnitManager.TryFind(spellDamageEvent.Target.PackedValue, out Unit target)) { return; } EventHandler.ExecuteEvent(GameEvents.SpellDamageDone, (Unit)LocalPlayer, target, spellDamageEvent.DamageAmount, (HitType)spellDamageEvent.HitType); }
public override void OnEvent(SpellHealingDoneEvent spellHealingEvent) { base.OnEvent(spellHealingEvent); if (LocalPlayer == null || !World.UnitManager.TryFind(spellHealingEvent.Target.PackedValue, out Unit target)) { return; } EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.SpellHealingDone, (Unit)LocalPlayer, target, spellHealingEvent.HealAmount, spellHealingEvent.IsCrit); }
public override void BoltShutdownBegin(AddCallback registerDoneCallback, UdpConnectionDisconnectReason disconnectReason) { base.BoltShutdownBegin(registerDoneCallback, disconnectReason); Debug.LogWarning($"Shutting down with reason: {disconnectReason}"); if (worldManager != null && worldManager.HasServerLogic) { EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.DisconnectedFromMaster); } }
public override void OnEvent(SpellMissDoneEvent spellMissEvent) { base.OnEvent(spellMissEvent); if (LocalPlayer == null || !World.UnitManager.TryFind(spellMissEvent.TargetId.PackedValue, out Unit target)) { return; } EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.SpellMissDone, (Unit)LocalPlayer, target, (SpellMissType)spellMissEvent.MissType); }
public override void ControlOfEntityLost(BoltEntity entity) { base.ControlOfEntityLost(entity); if (entity.StateIs <IPlayerState>()) { Assert.IsTrue(LocalPlayer.BoltEntity == entity, "Lost control of non-local player!"); EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.PlayerControlLost, LocalPlayer); LocalPlayer = null; } }
public override void ControlOfEntityLost(BoltEntity entity) { base.ControlOfEntityLost(entity); if (entity.StateIs <IPlayerState>()) { Assert.IsTrue(LocalPlayer.BoltEntity == entity, "Lost control of non-local player!"); EventHandler.ExecuteEvent(GameEvents.ClientControlStateChanged, LocalPlayer, false); LocalPlayer = null; } }
public override void ControlOfEntityGained(BoltEntity entity) { base.ControlOfEntityGained(entity); if (entity.StateIs <IPlayerState>()) { Assert.IsNull(LocalPlayer, "Gained control of another player while already controlling one!"); LocalPlayer = (Player)World.UnitManager.Find(entity.NetworkId.PackedValue); EventHandler.ExecuteEvent(GameEvents.ClientControlStateChanged, LocalPlayer, true); } }
public override void Disconnected(BoltConnection connection) { base.Disconnected(connection); if (networkingMode == NetworkingMode.Client) { StopAllCoroutines(); Debug.LogError("Disconnected: reason: " + connection.DisconnectReason); EventHandler.ExecuteEvent(GameEvents.DisconnectedFromHost, connection.DisconnectReason); } }
public void DestroyWorld() { if (world == null) { return; } EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.WorldStateChanged, world, false); world.Dispose(); world = null; }
public void DoUpdate() { if (hotkeyState == HotkeyState.Released && IsPressed) { hotkeyState = HotkeyState.Pressed; EventHandler.ExecuteEvent(this, GameEvents.HotkeyStateChanged, HotkeyState.Pressed); } else if (hotkeyState == HotkeyState.Pressed && !IsHotkeyDown) { hotkeyState = HotkeyState.Released; EventHandler.ExecuteEvent(this, GameEvents.HotkeyStateChanged, HotkeyState.Released); } }
public override void OnEvent(SpellCastRequestAnswerEvent answer) { base.OnEvent(answer); if (answer.Result == (int)SpellCastResult.Success) { var token = answer.ProcessingEntries as SpellProcessingToken; EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.SpellLaunched, (Unit)LocalPlayer, answer.SpellId, token); } else { EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.ClientSpellFailed, (SpellCastResult)answer.Result); } }
internal override int Set(int value) { int oldValue = CurrentValue; int newValue = Mathf.Clamp(value, MinValue, MaxValue); CurrentValue = newValue; if (oldValue != newValue) { EventHandler.ExecuteEvent(Entity, GameEvents.UnitAttributeChanged, AttributeType); } return(newValue - oldValue); }
internal override float Set(float value) { float oldValue = CurrentValue; float newValue = Mathf.Clamp(value, 0.0f, MaxValue); if (!Mathf.Approximately(oldValue, newValue)) { EventHandler.ExecuteEvent(Entity, GameEvents.UnitAttributeChanged, AttributeType); return(0.0f); } CurrentValue = newValue; return(newValue - oldValue); }
public void CreateWorld(World newWorld) { world = newWorld; EventHandler.ExecuteEvent(GameEvents.WorldStateChanged, world, true); }
public void CreateWorld(World newWorld) { world = newWorld; EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.WorldStateChanged, world, true); }
public override void SessionListUpdated(Map <Guid, UdpSession> sessionList) { base.SessionListUpdated(sessionList); EventHandler.ExecuteEvent(this, GameEvents.SessionListUpdated); }
private void ProcessTarget(SpellTargetEntry targetEntry) { if (targetEntry.Processed) { return; } targetEntry.Processed = true; if (targetEntry.Target.IsAlive != targetEntry.Alive) { return; } Unit caster = OriginalCaster ?? Caster; if (caster == null) { return; } SpellMissType missType = targetEntry.MissCondition; EffectDamage = 0; EffectHealing = 0; Unit hitTarget = targetEntry.Target; if (missType == SpellMissType.Reflect && targetEntry.ReflectResult == SpellMissType.None) { hitTarget = Caster; } missType = ProcessSpellHit(targetEntry); if (missType != SpellMissType.None) { EffectDamage = 0; } if (!spellValue.CastFlags.HasTargetFlag(SpellCastFlags.DontReportCastSuccess)) { EventHandler.ExecuteEvent(GameEvents.ServerSpellHit, Caster, hitTarget, SpellInfo, missType); } Caster.Spells.ApplySpellTriggers(SpellTriggerFlags.DoneSpellHit, hitTarget, this); if (EffectHealing > 0) { caster.Spells.HealBySpell(new SpellHealInfo(caster, targetEntry.Target, SpellInfo, (uint)EffectHealing, targetEntry.Crit)); } else if (EffectDamage > 0) { caster.Spells.DamageBySpell(new SpellDamageInfo(caster, targetEntry.Target, SpellInfo, (uint)EffectDamage, targetEntry.Crit, SpellDamageType.Direct), this); } if (missType == SpellMissType.None) { for (int effectIndex = 0; effectIndex < SpellInfo.Effects.Count; effectIndex++) { if (targetEntry.EffectMask.HasBit(effectIndex)) { SpellInfo.Effects[effectIndex].Handle(this, effectIndex, hitTarget, SpellEffectHandleMode.HitFinal); } } } else if (missType == SpellMissType.Immune && SpellInfo.SomeEffectsIgnoreSpellImmunity) { for (int effectIndex = 0; effectIndex < SpellInfo.Effects.Count; effectIndex++) { if (targetEntry.EffectMask.HasBit(effectIndex) && SpellInfo.Effects[effectIndex].IgnoresSpellImmunity) { SpellInfo.Effects[effectIndex].Handle(this, effectIndex, hitTarget, SpellEffectHandleMode.HitFinal); } } } if (missType != SpellMissType.Evade && !caster.IsFriendlyTo(hitTarget) && !SpellInfo.IsPositive) { caster.Combat.StartCombatWith(hitTarget); } }