public void InitShipWithBlueprint(Ship ship, BlueprintNew bp) { ship.Id = IdGenerator.GenShipId(); ship.Blueprint = bp; ShipClass shipClass = BlueprintManager.Instance.GetShipClass(bp.ShipClassId); ship.ShipClass = shipClass; // All ships have a cargo component CmpCargo cargo = ship.gameObject.AddComponent <CmpCargo>() as CmpCargo; foreach (string id in bp.ShipAttachmentIds) { var attachment = BlueprintManager.Instance.GetAttachment(id); AddAttachmentByType[attachment.Type](ship, attachment); } foreach (string id in bp.ShipThrusterIds) { var thruster = BlueprintManager.Instance.GetThruster(id); AddThruster(ship, thruster); } foreach (string id in bp.ShipEquipmentIds) { var equipment = BlueprintManager.Instance.GetEquipment(id); AddEquipmentByType[equipment.Type](ship, equipment); } InitShipComponents(ship); FinalizeShip(ship); }
void InitCmpCargo(Ship ship) { CmpCargo cmp = ship.gameObject.GetComponent <CmpCargo>(); if (!cmp) { return; } cmp.Init(ship); }
public MineCommand(Ship ship, IMineable target) { this._ship = ship; this._target = target; this._resourceData = ResourceManager.Instance.GetResource(this._target.GetResourceType()); this._cmpMining = ship.CmpMining; this._minedPerTick = _cmpMining.MinedPerTick; this._cmpCargo = ship.CmpCargo; this._miningProgress = 0; }