Esempio n. 1
0
 public LaserWeapon(CompleteStructure structure, RealLiveBlock block, WeaponConstants constants)
     : base(structure, block, constants)
 {
     _particles = Turret.GetComponent <ParticleSystem>();
     ParticleSystem.ShapeModule shape = _particles.shape;
     shape.position = Constants.TurretOffset;
 }
Esempio n. 2
0
 protected override void ServerFireWeapon(Vector3 point, RealLiveBlock block)
 {
     if (block != null)
     {
         block.GetComponentInParent <CompleteStructure>()
         .DamagedServer(new[] { new KeyValuePair <RealLiveBlock, uint>(block, block.Damage(400)) });
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Create a new system instance from the block if the block comes with a system.
        /// </summary>
        public static bool Create(CompleteStructure structure, RealLiveBlock block, out BotSystem system)
        {
            if (!Constructors.TryGetValue(block.Info.Type, out SystemConstructor constructor))
            {
                system = null;
                return(false);
            }

            system = constructor(structure, block);
            return(true);
        }
Esempio n. 4
0
        protected WeaponSystem(CompleteStructure structure, RealLiveBlock block, WeaponConstants constants)
            : base(structure, block)
        {
            Constants = constants;
            Turret    = block.transform.Find("Turret");

            if (!NetworkUtils.IsServer && !NetworkUtils.IsLocal(Structure.Id))
            {
                _turretRotationMultiplier *= 1.25f;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Called whenever the client receives the information that damage was dealt server-side.
        /// </summary>
        public void DamagedClient(BitBuffer buffer)
        {
            int count = buffer.TotalBitsLeft / (BlockPosition.SerializedBitsSize + 32);

            KeyValuePair <RealLiveBlock, uint>[] damages = new KeyValuePair <RealLiveBlock, uint> [count];
            for (int i = 0; i < count; i++)
            {
                RealLiveBlock block  = (RealLiveBlock)_blocks[BlockPosition.Deserialize(buffer)];
                uint          damage = buffer.ReadUInt();
                block.Damage(damage);
                damages[i] = new KeyValuePair <RealLiveBlock, uint>(block, damage);
            }
            DamageApply(damages);
        }
Esempio n. 6
0
        private void RemoveBlock(RealLiveBlock block)
        {
            Mass -= block.Info.Mass;
            Destroy(block.gameObject);
            _systems.TryRemove(block.Position);

            Assert.IsTrue(_blocks.Remove(block.Position), "The block is not present.");
            if (block is LiveMultiBlockParent parent)
            {
                foreach (LiveMultiBlockPart part in parent.Parts)
                {
                    Assert.IsTrue(_blocks.Remove(part.Position), "A part of the multi block is not present.");
                }
            }
        }
Esempio n. 7
0
        private void DamageApply(KeyValuePair <RealLiveBlock, uint>[] damages)
        {
            int status = 0;

            foreach (KeyValuePair <RealLiveBlock, uint> damage in damages)
            {
                Health -= damage.Value;
                if (Health * 100 < MaxHealth * MinHealthPercentage)
                {
                    status = 1;
                    break;
                }

                RealLiveBlock block = damage.Key;
                if (block.Health == 0)
                {
                    if (block.Info.Type == BlockType.Mainframe)
                    {
                        status = 1;
                        break;
                    }
                    else
                    {
                        RemoveBlock(block);
                        status = 2;
                    }
                }
            }

            if (status == 1)
            {
                Destroy(gameObject);
                UnityFixedDispatcher.InvokeDelayed(1000, () => LocalPlayingPlayerInitializer.RespawnPlayerStructure(Id));
            }
            else if (status == 2)
            {
                RemoveNotConnectedBlocks();
                ApplyMass(true);
            }
        }
Esempio n. 8
0
 public FullStopSystem(CompleteStructure structure, RealLiveBlock block) : base(structure, block)
 {
 }
Esempio n. 9
0
 protected override void ServerFireWeapon(Vector3 point, RealLiveBlock block)
 {
     //TODO currently no API is exposed which lets this scope get the connected blocks
     throw new System.NotImplementedException();
 }
Esempio n. 10
0
 protected PropulsionSystem(CompleteStructure structure, RealLiveBlock block) : base(structure, block)
 {
 }
Esempio n. 11
0
 protected override void ServerFireWeapon(Vector3 point, RealLiveBlock block)
 {
     throw new System.NotImplementedException();
 }
Esempio n. 12
0
 protected ProjectileWeapon(CompleteStructure structure, RealLiveBlock block, WeaponConstants constants)
     : base(structure, block, constants)
 {
 }
Esempio n. 13
0
 public ThrusterSystem(CompleteStructure structure, RealLiveBlock block, ThrusterConstants constants)
     : base(structure, block)
 {
     Constants = constants;
     _facing   = Rotation.RotateSides(constants.Facing, block.Rotation);
 }
Esempio n. 14
0
 protected ActiveSystem(CompleteStructure structure, RealLiveBlock block) : base(structure, block)
 {
 }
Esempio n. 15
0
 public UnrealAcceleratorSystem(CompleteStructure structure, RealLiveBlock block) : base(structure, block)
 {
 }
Esempio n. 16
0
 public PlasmaWeapon(CompleteStructure structure, RealLiveBlock block, WeaponConstants constants)
     : base(structure, block, constants)
 {
 }
Esempio n. 17
0
 protected BotSystem(CompleteStructure structure, RealLiveBlock block)
 {
     Structure = structure;
     Block     = block;
 }
Esempio n. 18
0
 protected abstract void ServerFireWeapon(Vector3 point, [CanBeNull] RealLiveBlock block);