Example #1
0
        public void OnRevive()
        {
            ZoomLevel = 1;

            if (IsLocalClient)
            {
                Input.ActionmapEvents.Add("zoom_in", OnZoomIn);
                Input.ActionmapEvents.Add("zoom_out", OnZoomOut);

                Input.ActionmapEvents.Add("moveright", OnRotateRight);
                Input.ActionmapEvents.Add("moveleft", OnRotateLeft);
                Input.ActionmapEvents.Add("moveforward", OnMoveForward);
                Input.ActionmapEvents.Add("moveback", OnMoveBack);
                Input.ActionmapEvents.Add("sprint", OnSprint);
            }

            OnDestroyed += (e) =>
            {
                if(IsLocalClient)
                    Input.ActionmapEvents.RemoveAll(this);

                if(m_turret != null)
                {
                    m_turret.Destroy();
                    m_turret = null;
                }
            };

            Reset(true);

            if (Network.IsMultiplayer)
                Entity.Spawn<Cursor>("Cursor", null, null, null, true, EntityFlags.CastShadow | EntityFlags.ClientOnly);
            else
                Entity.Spawn<Cursor>("Cursor");
        }
Example #2
0
        void NetReset(bool enteringGame, string turretTypeName)
        {
            if (enteringGame)
            {
                var turretType = System.Type.GetType(turretTypeName);

                m_turret = System.Activator.CreateInstance(turretType, this) as TankTurret;
            }
            else
            {
                m_turret.Destroy();
                m_turret = null;
            }
        }