public static StatefulCargo InstantiateStatefulCargo(StatefulCargoData data) { StatefulCargo c = null; switch (data.CargoType) { case StatefulCargoTypes.LaserTurret: { c = new CargoLaserTurret(data.Id, ((CargoLaserTurretData)data).Health, new LaserWeaponStats()); break; } case StatefulCargoTypes.DefensiveMine: { c = new StatefulCargo(data.Id, StatefulCargoTypes.DefensiveMine); break; } case StatefulCargoTypes.Module: { c = InstantiateModule((CargoModuleData)data); break; } default: Console.WriteLine("StatefulCargoType " + data.CargoType.ToString() + " not implemented in ReadNewShip."); break; } return(c); }
/// <summary> /// Writes stats to message. /// </summary> /// <param name="msg"></param> public virtual StatefulCargoData GetNetworkObject() { StatefulCargoData data = new StatefulCargoData(); data.CargoType = CargoType; data.Id = Id; return(data); }