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; }
protected override void ServerFireWeapon(Vector3 point, RealLiveBlock block) { if (block != null) { block.GetComponentInParent <CompleteStructure>() .DamagedServer(new[] { new KeyValuePair <RealLiveBlock, uint>(block, block.Damage(400)) }); } }
/// <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); }
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; } }
/// <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); }
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."); } } }
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); } }
public FullStopSystem(CompleteStructure structure, RealLiveBlock block) : base(structure, block) { }
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(); }
protected PropulsionSystem(CompleteStructure structure, RealLiveBlock block) : base(structure, block) { }
protected override void ServerFireWeapon(Vector3 point, RealLiveBlock block) { throw new System.NotImplementedException(); }
protected ProjectileWeapon(CompleteStructure structure, RealLiveBlock block, WeaponConstants constants) : base(structure, block, constants) { }
public ThrusterSystem(CompleteStructure structure, RealLiveBlock block, ThrusterConstants constants) : base(structure, block) { Constants = constants; _facing = Rotation.RotateSides(constants.Facing, block.Rotation); }
protected ActiveSystem(CompleteStructure structure, RealLiveBlock block) : base(structure, block) { }
public UnrealAcceleratorSystem(CompleteStructure structure, RealLiveBlock block) : base(structure, block) { }
public PlasmaWeapon(CompleteStructure structure, RealLiveBlock block, WeaponConstants constants) : base(structure, block, constants) { }
protected BotSystem(CompleteStructure structure, RealLiveBlock block) { Structure = structure; Block = block; }
protected abstract void ServerFireWeapon(Vector3 point, [CanBeNull] RealLiveBlock block);