Beispiel #1
0
        protected override void OnWorldStateChanged(World world, bool created)
        {
            if (created)
            {
                base.OnWorldStateChanged(world, true);

                EventHandler.RegisterEvent <Unit, Unit, int, HitType>(EventHandler.GlobalDispatcher, GameEvents.SpellDamageDone, OnSpellDamageDone);
                EventHandler.RegisterEvent <Unit, Unit, int, bool>(EventHandler.GlobalDispatcher, GameEvents.SpellHealingDone, OnSpellHealingDone);
                EventHandler.RegisterEvent <Unit, Unit, SpellMissType>(EventHandler.GlobalDispatcher, GameEvents.SpellMissDone, OnSpellMiss);
                EventHandler.RegisterEvent <Unit, int, SpellProcessingToken>(EventHandler.GlobalDispatcher, GameEvents.SpellLaunched, OnSpellLaunch);
                EventHandler.RegisterEvent <Unit, int>(EventHandler.GlobalDispatcher, GameEvents.SpellHit, OnSpellHit);

                nameplateController.Initialize();
                floatingTextController.Initialize();
                spellVisualController.Initialize();
                selectionCircleController.Initialize();
                unitRendererController.Initialize();
            }
            else
            {
                unitRendererController.Deinitialize();
                nameplateController.Deinitialize();
                selectionCircleController.Deinitialize();
                floatingTextController.Deinitialize();
                spellVisualController.Deinitialize();

                EventHandler.UnregisterEvent <Unit, Unit, int, HitType>(EventHandler.GlobalDispatcher, GameEvents.SpellDamageDone, OnSpellDamageDone);
                EventHandler.UnregisterEvent <Unit, Unit, int, bool>(EventHandler.GlobalDispatcher, GameEvents.SpellHealingDone, OnSpellHealingDone);
                EventHandler.UnregisterEvent <Unit, Unit, SpellMissType>(EventHandler.GlobalDispatcher, GameEvents.SpellMissDone, OnSpellMiss);
                EventHandler.UnregisterEvent <Unit, int, SpellProcessingToken>(EventHandler.GlobalDispatcher, GameEvents.SpellLaunched, OnSpellLaunch);
                EventHandler.UnregisterEvent <Unit, int>(EventHandler.GlobalDispatcher, GameEvents.SpellHit, OnSpellHit);

                base.OnWorldStateChanged(world, false);
            }
        }
Beispiel #2
0
        internal void Unregister()
        {
            EventHandler.UnregisterEvent <WorldManager>(EventHandler.GlobalDispatcher, GameEvents.WorldInitialized, OnWorldInitialized);
            EventHandler.UnregisterEvent <WorldManager>(EventHandler.GlobalDispatcher, GameEvents.WorldDeinitializing, OnWorldDeinitializing);

            SetListeners(false, false, false);
        }
Beispiel #3
0
        private void OnMapLoaded(string map, NetworkingMode mode)
        {
            Assert.AreEqual(mode, NetworkingMode.Server);

            worldManager = new WorldServerManager(false);
            EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.WorldInitialized, worldManager);
        }
Beispiel #4
0
        public void Modify(KeyCode keyCode, HotkeyModifier modifier)
        {
            appliedKey      = keyCode;
            appliedModifier = modifier;

            EventHandler.ExecuteEvent(this, GameEvents.HotkeyBindingChanged);
        }
        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();
            }
        }
Beispiel #6
0
        protected override void OnWorldDeinitializing(WorldManager world)
        {
            if (world.HasClientLogic)
            {
                nameplateController.Deinitialize();
                selectionCircleController.Deinitialize();
                floatingTextController.Deinitialize();
                spellVisualController.Deinitialize();

                EventHandler.UnregisterEvent <Unit, Unit, int, bool>(EventHandler.GlobalDispatcher, GameEvents.SpellDamageDone, OnSpellDamageDone);
                EventHandler.UnregisterEvent <Unit, Unit, int, bool>(EventHandler.GlobalDispatcher, GameEvents.SpellHealingDone, OnSpellHealingDone);
                EventHandler.UnregisterEvent <Unit, int, SpellProcessingToken, Vector3>(EventHandler.GlobalDispatcher, GameEvents.SpellLaunched, OnSpellLaunch);
                EventHandler.UnregisterEvent <Unit, int>(EventHandler.GlobalDispatcher, GameEvents.SpellHit, OnSpellHit);

                world.UnitManager.EventEntityAttached -= OnEventEntityAttached;
                world.UnitManager.EventEntityDetach   -= OnEventEntityDetach;

                foreach (UnitRenderer unitRenderer in unitRenderers)
                {
                    unitRenderer.Deinitialize();
                }

                unitRenderersById.Clear();
                unitRenderers.Clear();
            }

            base.OnWorldDeinitializing(world);
        }
Beispiel #7
0
            public void HandlePlayerControlLost()
            {
                playerCircle.UpdateUnit(null);
                targetCircle.UpdateUnit(null);

                EventHandler.UnregisterEvent(renderingReference.Player, GameEvents.UnitTargetChanged, onPlayerTargetChanged);
            }
Beispiel #8
0
            public void HandlePlayerControlGained()
            {
                playerCircle.UpdateUnit(renderingReference.Player);
                targetCircle.UpdateUnit(renderingReference.Player.Target);

                EventHandler.RegisterEvent(renderingReference.Player, GameEvents.UnitTargetChanged, onPlayerTargetChanged);
            }
        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();
            }
        }
Beispiel #10
0
        protected override void OnUnregister()
        {
            EventHandler.UnregisterEvent <string, NetworkingMode>(EventHandler.GlobalDispatcher, GameEvents.GameMapLoaded, OnMapLoaded);
            EventHandler.UnregisterEvent(EventHandler.GlobalDispatcher, GameEvents.DisconnectedFromMaster, OnDisconnectedFromMaster);

            restartCount = 0;
            tokenSource.Cancel();
        }
Beispiel #11
0
        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);
                }
            }
        }
Beispiel #12
0
        private void OnApplicationQuit()
        {
            EventHandler.UnregisterEvent <WorldManager>(EventHandler.GlobalDispatcher, GameEvents.WorldInitialized, OnWorldInitialized);
            EventHandler.UnregisterEvent <WorldManager>(EventHandler.GlobalDispatcher, GameEvents.WorldDeinitializing, OnWorldDeinitializing);

            world?.Dispose();
            scriptableClientContainer.Unregister();
            scriptableCoreContainer.Unregister();
        }
        internal void Register()
        {
            config = BoltRuntimeSettings.instance.GetConfigCopy();
            config.connectionRequestTimeout = (int)(MaxConnectionAttemptTime * 1000.0f);

            SetListeners(false, false, false);

            EventHandler.RegisterEvent <World, bool>(GameEvents.WorldStateChanged, OnWorldStateChanged);
        }
        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);
            }
        }
Beispiel #16
0
        protected override void OnRegistered()
        {
            settings.Apply();

            EventHandler.RegisterEvent <string, NetworkingMode>(EventHandler.GlobalDispatcher, GameEvents.GameMapLoaded, OnMapLoaded);
            EventHandler.RegisterEvent(EventHandler.GlobalDispatcher, GameEvents.DisconnectedFromMaster, OnDisconnectedFromMaster);

            StartServer();
        }
        private void Deinitialize()
        {
            EventHandler.UnregisterEvent(UnitRenderer.Unit, GameEvents.UnitFactionChanged, onFactionChangedAction);

            castFrame.UpdateCaster(null);
            healthFrame.Unit = null;

            UnitRenderer = null;
        }
Beispiel #18
0
        private void DeinitializeUnit()
        {
            EventHandler.UnregisterEvent(unit, GameEvents.UnitAttributeChanged, onAttributeChangedAction);
            EventHandler.UnregisterEvent(unit, GameEvents.UnitTargetChanged, onUnitTargetChanged);

            targetUnitFrame?.UpdateUnit(null);
            unitBuffDisplayFrame?.UpdateUnit(null);

            unit = null;
        }
Beispiel #19
0
        protected override void OnRegistered()
        {
            gameManager = FindObjectOfType <GameManager>();
            settings.Apply();

            EventHandler.RegisterEvent <string, NetworkingMode>(GameEvents.GameMapLoaded, OnMapLoaded);
            EventHandler.RegisterEvent(GameEvents.DisconnectedFromMaster, OnDisconnectedFromMaster);

            StartServer();
        }
Beispiel #20
0
        internal void Register()
        {
            config = BoltRuntimeSettings.instance.GetConfigCopy();
            config.connectionRequestTimeout = (int)(MaxConnectionAttemptTime * 1000.0f);

            SetListeners(false, false, false);

            EventHandler.RegisterEvent <WorldManager>(EventHandler.GlobalDispatcher, GameEvents.WorldInitialized, OnWorldInitialized);
            EventHandler.RegisterEvent <WorldManager>(EventHandler.GlobalDispatcher, GameEvents.WorldDeinitializing, OnWorldDeinitializing);
        }
Beispiel #21
0
            public void Initialize()
            {
                Assert.IsTrue(unitRendererHandlers.Count == 0);
                Assert.IsTrue(unitRenderers.Count == 0);
                Assert.IsTrue(unitRenderersById.Count == 0);
                Assert.IsTrue(detachedUnits.Count == 0);

                rendering.World.UnitManager.EventEntityAttached += OnEventEntityAttached;
                rendering.World.UnitManager.EventEntityDetach   += OnEventEntityDetach;
                EventHandler.RegisterEvent <WorldEntity, bool>(rendering.World, GameEvents.ServerVisibilityChanged, OnServerVisibilityChanged);
            }
Beispiel #22
0
        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 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);
        }
Beispiel #25
0
        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);
        }
Beispiel #26
0
        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);
            }
        }
Beispiel #28
0
        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;
            }
        }
Beispiel #29
0
        public void DestroyWorld()
        {
            if (world == null)
            {
                return;
            }

            EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.WorldStateChanged, world, false);

            world.Dispose();
            world = null;
        }
Beispiel #30
0
        private void Awake()
        {
            DontDestroyOnLoad(gameObject);

            scriptableCoreContainer.Register();
            scriptableClientContainer.Register();

            gameTimer.Start();

            EventHandler.RegisterEvent <WorldManager>(EventHandler.GlobalDispatcher, GameEvents.WorldInitialized, OnWorldInitialized);
            EventHandler.RegisterEvent <WorldManager>(EventHandler.GlobalDispatcher, GameEvents.WorldDeinitializing, OnWorldDeinitializing);
        }