Ejemplo n.º 1
0
        public ShipDataOutputMessage(NetIncomingMessage msg)
        {
            Nose = msg.ReadInt32();
            Core = msg.ReadInt32();
            Engine = msg.ReadInt32();

            GeneratedData = new ShipData(Nose, Core, Engine);

            GeneratedData.NoseColor = new Color(msg.ReadByte(), msg.ReadByte(), msg.ReadByte());
            GeneratedData.CoreColor = new Color(msg.ReadByte(), msg.ReadByte(), msg.ReadByte());
            GeneratedData.TailColor = new Color(msg.ReadByte(), msg.ReadByte(), msg.ReadByte());
            GeneratedData.WeaponColor = new Color(msg.ReadByte(), msg.ReadByte(), msg.ReadByte());

            int length = msg.ReadInt32();
            Weapons = new int[length];
            FireGroups = new byte[length];
            for (int i = 0; i < length; i++)
            {
                Weapons[i] = msg.ReadInt32();
                FireGroups[i] = msg.ReadByte();
                Vector3? freeSlot = FreeSlot(GeneratedData.Nose);
                if (freeSlot != null)
                {
                    GeneratedData.SetWeapon((Vector3)freeSlot, Weapons[i], FireGroups[i]);
                    continue;
                }
                freeSlot = FreeSlot(GeneratedData.Core);
                if (freeSlot != null)
                {
                    GeneratedData.SetWeapon((Vector3)freeSlot, Weapons[i], FireGroups[i]);
                    continue;
                }
                freeSlot = FreeSlot(GeneratedData.Engine);
                if (freeSlot != null)
                {
                    GeneratedData.SetWeapon((Vector3)freeSlot, Weapons[i], FireGroups[i]);
                    continue;
                }
            }
            GeneratedData.WeaponIDs = Weapons;
        }
Ejemplo n.º 2
0
        public ShipObj(Vector3 position, Quaternion orientation, ShipData data)
            : base()
        {
            Data = data;
            Data.ComposeHitbox();
            Data.Hitbox.Position = position;
            Data.Hitbox.Orientation = orientation;
            this.SetEntity(Data.Hitbox, 2);

            Health = Data.TotalArmor;
            Thrusters = new SingleEntityLinearMotor(Entity, Position);
            ControlSurfaces = new SingleEntityAngularMotor(Entity);
            ControlSurfaces.Settings.Mode = MotorMode.Servomechanism;

            Thrusters.Settings.Mode = MotorMode.VelocityMotor;
            Thrusters.Settings.VelocityMotor.Softness = 0.002f;
            Entity.IsAffectedByGravity = true;

            Sector.Redria.Space.Add(Thrusters);
            Sector.Redria.Space.Add(ControlSurfaces);
            Network.AddShip();
        }