public virtual Ship CreatePlayerShip(World world, Vector2 position, int shipID, float rotation, Vector2 velocity, string playerName, ShipStats shipStats, List <WeaponTypes> weaponTypes, HashSet <int> teams) { if (PlayerShip != null) { _teamManager.DeRegisterObject(PlayerShip); _targetManager.DeRegisterObject(PlayerShip); if (PlayerShip.IsBodyValid) { Debugging.DisposeStack.Push(this.ToString()); PlayerShip.Body.Dispose(); } } if (_shipList.ContainsKey(shipID)) { _positionUpdateList.Remove(_shipList[shipID]); _shipList.Remove(shipID); } Ship tempShip; switch (shipStats.ShipType) { case ShipTypes.Barge: tempShip = new Barge(position, velocity, rotation, shipID, (int)_clientPlayerInfoManager.PlayerID, playerName, shipStats, _particleManager, world, _spriteBatch, GetTexture(shipStats.ShipType), teams); break; case ShipTypes.SuperCoolAwesome3DShip: tempShip = new SuperCoolAwesome3DShip(_spriteBatch, GetModel(shipStats.ShipType), position, velocity, rotation, shipID, (int)_clientPlayerInfoManager.PlayerID, playerName, shipStats, _particleManager, world, teams); break; case ShipTypes.Reaper: tempShip = new Reaper(position, velocity, rotation, shipID, (int)_clientPlayerInfoManager.PlayerID, playerName, shipStats, _particleManager, world, _spriteBatch, GetTexture(shipStats.ShipType), teams); break; case ShipTypes.BattleCruiser: tempShip = new Battlecruiser(position, velocity, rotation, shipID, (int)_clientPlayerInfoManager.PlayerID, playerName, shipStats, _particleManager, world, _spriteBatch, GetTexture(shipStats.ShipType), teams); break; case ShipTypes.Penguin: tempShip = new Penguin(position, velocity, rotation, shipID, (int)_clientPlayerInfoManager.PlayerID, playerName, shipStats, _particleManager, world, _spriteBatch, GetTexture(shipStats.ShipType), teams); break; case ShipTypes.Dread: tempShip = new Dread(position, velocity, rotation, shipID, (int)_clientPlayerInfoManager.PlayerID, playerName, shipStats, _particleManager, world, _spriteBatch, GetTexture(shipStats.ShipType), teams); break; default: Console.WriteLine("Ship type not implemented in ClientShipManager.CreatePlayerShip"); return(null); } byte slot = 0; foreach (var w in weaponTypes) { tempShip.SetWeapon(_createWeapon(tempShip, _projectileManager, w, slot), slot); slot++; } SetPilot(tempShip, Debugging.IsBot); _shipList.Add(tempShip.Id, tempShip); _positionUpdateList.Add(tempShip); _playerShipManager.PlayerShip = tempShip; _teamManager.RegisterObject(tempShip); _updateIgnoreList.Add(PlayerShip.Id); tempShip.CanLandWarp = true; return(tempShip); }
/// <summary> /// Used to create new network or NPC ships /// DO NOT USE FOR PLAYERSHIP /// ignorePositionUpdates should only be used by the Simulator /// </summary> public Ship CreateShip(World world, bool isNPC, Vector2 position, int shipID, float rotation, Vector2 velocity, string playerName, ShipStats shipStats, List <WeaponTypes> weaponTypes, HashSet <int> teams, bool ignorePositionUpdates = false) { Ship tempShip; _targetManager.DisableTargetSetting(); switch (shipStats.ShipType) { case ShipTypes.Barge: tempShip = new Barge(position, velocity, rotation, shipID, 0, playerName, shipStats, _particleManager, world, _spriteBatch, GetTexture(shipStats.ShipType), teams); tempShip.Pilot = new NetworkPilot(tempShip, new ShipBodyDataObject(BodyTypes.NetworkShip, shipID, tempShip)); break; case ShipTypes.Reaper: tempShip = new Reaper(position, velocity, rotation, shipID, 0, playerName, shipStats, _particleManager, world, _spriteBatch, GetTexture(shipStats.ShipType), teams); tempShip.Pilot = new NetworkPilot(tempShip, GenerateNetworkShipBodyData(shipID, tempShip)); break; case ShipTypes.SuperCoolAwesome3DShip: tempShip = new SuperCoolAwesome3DShip(_spriteBatch, GetModel(shipStats.ShipType), position, velocity, rotation, shipID, 0, playerName, shipStats, _particleManager, world, teams); tempShip.Pilot = new NetworkPilot(tempShip, new ShipBodyDataObject(BodyTypes.NetworkShip, shipID, tempShip)); break; case ShipTypes.BattleCruiser: tempShip = new Battlecruiser(position, velocity, rotation, shipID, 0, playerName, shipStats, _particleManager, world, _spriteBatch, GetTexture(shipStats.ShipType), teams); tempShip.Pilot = new NetworkPilot(tempShip, GenerateNetworkShipBodyData(shipID, tempShip)); break; case ShipTypes.Penguin: tempShip = new Penguin(position, velocity, rotation, shipID, 0, playerName, shipStats, _particleManager, world, _spriteBatch, GetTexture(shipStats.ShipType), teams); tempShip.Pilot = new NetworkPilot(tempShip, GenerateNetworkShipBodyData(shipID, tempShip)); break; case ShipTypes.Dread: tempShip = new Dread(position, velocity, rotation, shipID, 0, playerName, shipStats, _particleManager, world, _spriteBatch, GetTexture(shipStats.ShipType), teams); tempShip.Pilot = new NetworkPilot(tempShip, GenerateNetworkShipBodyData(shipID, tempShip)); break; default: ConsoleManager.WriteLine("Ship type not implemented in ClientShipManager.CreateShip", ConsoleMessageType.Error); return(null); } if (!_simulateNPCs || tempShip.Pilot.PilotType == PilotType.NetworkPlayer) { tempShip.BodyBehaviors.Add(new LerpBodyBehavior(_spriteBatch, _textureManager, tempShip, 100)); } tempShip.IsLocalSim = (_simulateNPCs && isNPC); AddShip(shipID, tempShip); byte numSet = 0; foreach (var t in weaponTypes) { tempShip.SetWeapon(_createWeapon(tempShip, _projectileManager, t, numSet), numSet); numSet++; } tempShip.Pilot = isNPC ? new NPCPilot(tempShip, GenerateNetworkShipBodyData(shipID, tempShip)) : new NPCPilot(tempShip, new ShipBodyDataObject(BodyTypes.NetworkShip, shipID, tempShip)); if (ignorePositionUpdates) { _updateIgnoreList.Add(tempShip.Id); } _targetManager.EnableTargetSetting(); return(tempShip); }