Пример #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;
 }
Пример #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)) });
     }
 }
Пример #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);
        }
Пример #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;
            }
        }
Пример #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);
        }
Пример #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.");
                }
            }
        }
Пример #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);
            }
        }
Пример #8
0
 public FullStopSystem(CompleteStructure structure, RealLiveBlock block) : base(structure, block)
 {
 }
Пример #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();
 }
Пример #10
0
 protected PropulsionSystem(CompleteStructure structure, RealLiveBlock block) : base(structure, block)
 {
 }
Пример #11
0
 protected override void ServerFireWeapon(Vector3 point, RealLiveBlock block)
 {
     throw new System.NotImplementedException();
 }
Пример #12
0
 protected ProjectileWeapon(CompleteStructure structure, RealLiveBlock block, WeaponConstants constants)
     : base(structure, block, constants)
 {
 }
Пример #13
0
 public ThrusterSystem(CompleteStructure structure, RealLiveBlock block, ThrusterConstants constants)
     : base(structure, block)
 {
     Constants = constants;
     _facing   = Rotation.RotateSides(constants.Facing, block.Rotation);
 }
Пример #14
0
 protected ActiveSystem(CompleteStructure structure, RealLiveBlock block) : base(structure, block)
 {
 }
Пример #15
0
 public UnrealAcceleratorSystem(CompleteStructure structure, RealLiveBlock block) : base(structure, block)
 {
 }
Пример #16
0
 public PlasmaWeapon(CompleteStructure structure, RealLiveBlock block, WeaponConstants constants)
     : base(structure, block, constants)
 {
 }
Пример #17
0
 protected BotSystem(CompleteStructure structure, RealLiveBlock block)
 {
     Structure = structure;
     Block     = block;
 }
Пример #18
0
 protected abstract void ServerFireWeapon(Vector3 point, [CanBeNull] RealLiveBlock block);