public void SetModule(ModuleBluePrint m) { if (m == null) { return; } if (networkObject.IsServer) { networkObject.SendRpc(RPC_UPDATE_MODULE, Receivers.All, m.Id, m.key, m.speed, m.acceleration, m.agility, m.health, m.shield, m.flipped); } }
public override void SetSlotItem(RpcArgs args) { var slotId = args.GetNext <int>(); var itemKey = args.GetNext <string>(); var amount = args.GetNext <int>(); var byteArray = args.GetNext <byte[]>(); var attributes = new ItemAttributeObject(); SetItem(slotId, itemKey, amount, attributes); if (networkObject.IsServer) { var slot = Slots.First(s => s.id == slotId); if (slot == null) { return; } if (slot.slotType == InventorySlot.SlotType.Engine || slot.slotType == InventorySlot.SlotType.Weapon || slot.slotType == InventorySlot.SlotType.Hull || slot.slotType == InventorySlot.SlotType.Wing) { var item = ItemManager.Instance.GetItem(itemKey); if (item == null) { return; } var meta = item.GetComponent <ItemMeta>(); var bluePrint = new ModuleBluePrint { key = itemKey, Id = slot.id, acceleration = meta.baseAcceleration + attributes.acceleration, speed = meta.baseSpeed + attributes.speed, agility = meta.baseAgility + attributes.agility, health = meta.baseHealth + attributes.health, shield = meta.baseShield + attributes.shield, }; if (slot.id == 1002) { bluePrint.flipped = true; } getPlayer().ship.SetModule(bluePrint); } } }
public void Spawn() { if (ship != null) { ship.networkObject.Destroy(); } ship = NetworkManager.Instance.InstantiateEntity() as PlayerShip; ship.networkObject.ownershipChanged += (thing) => ship.SendInitRPC(); ship.networkReady += () => { ModuleBluePrint hull = new ModuleBluePrint { Id = 1000, key = "testHull", flipped = false, health = 850, shield = 250, }; ship.SetModule(hull); ModuleBluePrint rightWing = new ModuleBluePrint { Id = 1002, key = "testWing", flipped = true, agility = 2, shield = 250, health = 50, }; ship.SetModule(rightWing); ModuleBluePrint leftWing = new ModuleBluePrint { Id = 1001, key = "testWing", agility = 4, shield = 250, health = 50, }; ship.SetModule(leftWing); ModuleBluePrint engine = new ModuleBluePrint { Id = 1003, key = "defaultEngine", shield = 100, health = 50, acceleration = 0.055f, speed = 0.01f, }; ship.SetModule(engine); ModuleBluePrint turret = new ModuleBluePrint { Id = 4, key = "defaultTurret", shield = 100, health = 50, acceleration = 0.055f, speed = 0.01f, }; ship.SetModule(turret); ship.Team = Username; ship.Name = Username; ship.Health = ship.MaxHealth; ship.Shield = ship.MaxShield; ship.networkObject.AssignOwnership(networkObject.Owner); }; }