示例#1
0
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnDeleteSubscribedToDeletionEvent(Entity)"/></summary>
        protected override void OnDeleteSubscribedToDeletionEvent(Entity entity)
        {
            base.OnDeleteSubscribedToDeletionEvent(entity);

            if (entity == destination)
            {
                destination = null;
            }
        }
示例#2
0
        public void ReceiveObject(MapObject obj, BoxTeleporter source)
        {
            if (!string.IsNullOrEmpty(Type.ReceiveParticleName))
            {
                Map.Instance.CreateAutoDeleteParticleSystem(Type.ReceiveParticleName, Position);
            }

            if (source == null)
            {
                float offset = obj.Position.Z - obj.PhysicsModel.GetGlobalBounds().Minimum.Z;
                obj.Position = Position + new Vec3(0, 0, offset);
                obj.Rotation = Rotation;
                obj.SetOldTransform(obj.Position, obj.Rotation, obj.Scale);
            }
            else
            {
                //iNCIN this is not correct -- needs to be fixed
                Quat destRotation = Rotation * Mat3.FromRotateByZ(new Degree(180).InRadians()).ToQuat();

                foreach (Body body in obj.PhysicsModel.Bodies)
                {
                    body.Rotation = body.Rotation * source.Rotation.GetInverse() * destRotation;
                    Vec3 localPosOffset = (body.Position - source.Position) * source.Rotation.GetInverse();
                    body.Position    = Position + localPosOffset * destRotation;
                    body.OldPosition = body.Position;
                    body.OldRotation = body.Rotation;

                    body.LinearVelocity  = body.LinearVelocity * source.Rotation.GetInverse() * destRotation;
                    body.AngularVelocity = body.AngularVelocity * source.Rotation.GetInverse() * destRotation;
                }

                obj.UpdatePositionAndRotationByPhysics(true);
                obj.SetOldTransform(obj.Position, obj.Rotation, obj.Scale);

                Unit unit = obj as Unit;
                if (unit != null)
                {
                    PlayerIntellect playerIntellect = unit.Intellect as PlayerIntellect;
                    if (playerIntellect != null)
                    {
                        Vec3 vec = playerIntellect.LookDirection.GetVector();
                        Vec3 v   = vec * source.Rotation.GetInverse() * destRotation;
                        playerIntellect.LookDirection = SphereDir.FromVector(v);
                    }
                }
            }

            //add object to the list of processed objects. object can't activate teleportation.
            processedObjectsInActiveArea.AddWithCheckAlreadyContained(obj);
        }
        public void ReceiveObject(MapObject obj, BoxTeleporter source)
        {
            if (!string.IsNullOrEmpty(Type.ReceiveParticleName))
                Map.Instance.CreateAutoDeleteParticleSystem(Type.ReceiveParticleName, Position);

            if (source == null)
            {
                float offset = obj.Position.Z - obj.PhysicsModel.GetGlobalBounds().Minimum.Z;
                obj.Position = Position + new Vec3(0, 0, offset);
                obj.Rotation = Rotation;
                obj.SetOldTransform(obj.Position, obj.Rotation, obj.Scale);
            }
            else
            {
                //iNCIN this is not correct -- needs to be fixed
                Quat destRotation = Rotation * Mat3.FromRotateByZ(new Degree(180).InRadians()).ToQuat();

                foreach (Body body in obj.PhysicsModel.Bodies)
                {
                    body.Rotation = body.Rotation * source.Rotation.GetInverse() * destRotation;
                    Vec3 localPosOffset = (body.Position - source.Position) * source.Rotation.GetInverse();
                    body.Position = Position + localPosOffset * destRotation;
                    body.OldPosition = body.Position;
                    body.OldRotation = body.Rotation;

                    body.LinearVelocity = body.LinearVelocity * source.Rotation.GetInverse() * destRotation;
                    body.AngularVelocity = body.AngularVelocity * source.Rotation.GetInverse() * destRotation;
                }

                obj.UpdatePositionAndRotationByPhysics(true);
                obj.SetOldTransform(obj.Position, obj.Rotation, obj.Scale);

                Unit unit = obj as Unit;
                if (unit != null)
                {
                    PlayerIntellect playerIntellect = unit.Intellect as PlayerIntellect;
                    if (playerIntellect != null)
                    {
                        Vec3 vec = playerIntellect.LookDirection.GetVector();
                        Vec3 v = vec * source.Rotation.GetInverse() * destRotation;
                        playerIntellect.LookDirection = SphereDir.FromVector(v);
                    }
                }
            }

            //add object to the list of processed objects. object can't activate teleportation.
            processedObjectsInActiveArea.AddWithCheckAlreadyContained(obj);
        }
示例#4
0
        private Unit ServerOrSingle_CreatePlayerUnit(PlayerManager.ServerOrSingle_Player player,
                                                     MapObject spawnPoint)
        {
            string unitTypeName;

            if (!player.Bot)
            {
                if (player.Intellect.Faction.Name == "AssaultKnights" && GameMap.Instance.GameType == GameMap.GameTypes.AssaultKnights)
                {
                    unitTypeName = "AKSoldier";
                }
                else if (player.Intellect.Faction.Name == "Omni" && GameMap.Instance.GameType == GameMap.GameTypes.AssaultKnights)
                {
                    unitTypeName = "OmniSoldier";
                }
                else if (GameMap.Instance.PlayerUnitType != null)
                {
                    unitTypeName = GameMap.Instance.PlayerUnitType.Name;
                }
                else
                {
                    unitTypeName = "Girl";
                }
            }
            else if (player.Bot)
            {
                unitTypeName = player.Name;
            }
            else
            {
                unitTypeName = "Rabbit";
            }

            Unit unit = (Unit)Entities.Instance.Create(unitTypeName, Map.Instance);

            Vec3 posOffset = new Vec3(0, 0, 1.5f);

            unit.Position = spawnPoint.Position + posOffset;
            unit.Rotation = spawnPoint.Rotation;
            unit.PostCreate();

            if (player.Intellect != null)
            {
                player.Intellect.ControlledObject = unit;
                unit.SetIntellect(player.Intellect, false);
            }

            Teleporter teleporter = spawnPoint as Teleporter;

            if (teleporter != null)
            {
                teleporter.ReceiveObject(unit, null);
            }

            //Incin -- Custom Box teleporter
            BoxTeleporter boxteleporter = spawnPoint as BoxTeleporter;

            if (boxteleporter != null)
            {
                boxteleporter.ReceiveObject(unit, null);
            }

            return(unit);
        }
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnDeleteSubscribedToDeletionEvent(Entity)"/></summary>
        protected override void OnDeleteSubscribedToDeletionEvent(Entity entity)
        {
            base.OnDeleteSubscribedToDeletionEvent(entity);

            if (entity == destination)
                destination = null;
        }