public void Initialise(GameVM gameVM, StarSystem starSys, Entity viewingFaction) { _viewingFaction = viewingFaction; var listnerblobs = new List <int>(); listnerblobs.Add(EntityManager.DataBlobTypes[typeof(OwnedDB)]); listnerblobs.Add(EntityManager.DataBlobTypes[typeof(PositionDB)]); EntityChangeListner changeListner = new EntityChangeListner(starSys, viewingFaction, listnerblobs); _changeListner = changeListner; IconableEntitys.Clear(); _iconableEntites.Clear(); foreach (Entity entity in _changeListner.ListningToEntites) { AddIconableEntity(entity); } SystemSubpulse = starSys.ManagerSubpulses; //starSys.SystemManager.GetAllEntitiesWithDataBlob<NewtonBalisticDB>(gameVM.CurrentAuthToken); OnPropertyChanged(nameof(IconableEntitys)); }
public ColonyScreenVM(GameVM gameVM, Entity colonyEntity, StaticDataStore staticData) { gameVM.Game.GameLoop.GameGlobalDateChangedEvent += GameVM_DateChangedEvent; _colonyEntity = colonyEntity; _facilities = new ObservableCollection <FacilityVM>(); ComponentInstancesDB instaces = colonyEntity.GetDataBlob <ComponentInstancesDB>(); foreach (var installation in instaces.SpecificInstances) { //Facilities.Add(new FacilityVM(installation.Key, instaces)); FacilitesList.Add(new ComponentSpecificDesignVM(installation.Key, installation.Value)); } UpdatePop(); CommandReferences cmdRef = new CommandReferences(FactionEntity.Guid, _colonyEntity.Guid, gameVM.Game.OrderHandler, _colonyEntity.Manager.ManagerSubpulses); CargoStoreVM = new CargoStorageVM(staticData, cmdRef, colonyEntity.GetDataBlob <CargoStorageDB>()); PlanetMineralDepositVM = new PlanetMineralDepositVM(staticData, _colonyEntity.GetDataBlob <ColonyInfoDB>().PlanetEntity); RefineryAbilityVM = new RefineryAbilityVM(staticData, _colonyEntity); ConstructionAbilityVM = new ConstructionAbilityVM(staticData, _colonyEntity); ColonyResearchVM = new ColonyResearchVM(staticData, _colonyEntity); }
internal static PlanetVM Create(GameVM gameVM, Entity entity, StarVM parent_star) { var newvm = PlanetVM.Create(gameVM, entity); newvm.ParentStar = parent_star; return(newvm); }
public ShipOrderVM(GameVM game) { _gameVM = game; FactionInfoDB finfo = _gameVM.CurrentFaction.GetDataBlob <FactionInfoDB>(); foreach (StarSystem starSystem in _gameVM.StarSystemSelectionViewModel.StarSystems.Keys) { if (finfo.KnownSystems.Contains(starSystem.Guid)) { _starSystems.Add(starSystem, starSystem.NameDB.GetName(_gameVM.CurrentFaction)); } } _starSystems.SelectedIndex = 0; TargetShown = false; TargetAreaWidth = 2; RefreshShips(0, 0); //PropertyChanged += ShipOrderVM_PropertyChanged; SelectedSystem.ManagerSubpulses.SystemDateChangedEvent += UpdateInterface_SystemDateChangedEvent; _starSystems.SelectionChangedEvent += RefreshShips; _shipList.SelectionChangedEvent += RefreshOrders; _shipList.SelectionChangedEvent += RefreshFireControlList; _moveOrdersPossible.SelectionChangedEvent += RefreshTarget; _moveTargetList.SelectionChangedEvent += RefreshTargetDistance; _fireControlList.SelectionChangedEvent += RefreshBeamWeaponsList; _fireControlList.SelectionChangedEvent += RefreshFCTarget; OnPropertyChanged(nameof(StarSystems)); OnPropertyChanged(nameof(SelectedSystem)); }
public MissileDesignVM(GameVM gameVM) { List <ChainedSliderVM> chainedSlidersVM = new List <ChainedSliderVM>(); chainedSlidersVM.Add(new ChainedSliderVM()); chainedSlidersVM[0].Name = "Payload"; chainedSlidersVM.Add(new ChainedSliderVM()); chainedSlidersVM[1].Name = "Engine"; chainedSlidersVM.Add(new ChainedSliderVM()); chainedSlidersVM[2].Name = "Agility"; chainedSlidersVM.Add(new ChainedSliderVM()); chainedSlidersVM[3].Name = "Fuel"; chainedSlidersVM.Add(new ChainedSliderVM()); chainedSlidersVM[4].Name = "EW and Armor"; ChainedSliders = new ChainedSliders(chainedSlidersVM); //TODO: how are we going to define the warheads? can they just be another design entity with just an explosive datablob or something? below is just a placeholder. Payload explosive = new Payload(); explosive.Name = "Explosive Charge"; explosive.Damage = 1; PayloadTypes.Add(explosive, explosive.Name); foreach (var design in gameVM.CurrentFaction.GetDataBlob <FactionInfoDB>().MissileDesigns) { Payload payload = new Payload(design.Value); PayloadTypes.Add(payload, payload.Name); } }
public EntityVM(GameVM gamevm) { _game = gamevm.Game; if (gamevm.CurrentFaction != null && gamevm.CurrentFaction.IsValid) { Init(gamevm.CurrentFaction); } }
public ClientConnectionVM(GameVM gameVM) { _netClient = new NetworkClient(ServerAddress, PortNum, gameVM); NetMessages = _netClient.Messages; gameVM.NetMessages = _netClient.Messages; //_connectCMD = new CommandHandler(OnConnectToFactionCMD, false); }
/// <summary> /// Creates and fills out the properties of this ViewModel from the provided entity. /// </summary> public static SystemVM Create(GameVM gameVM, StarSystem starSystem) { SystemVM newVM = new SystemVM(gameVM, starSystem); // Initialize the data. newVM.Refresh(); return(newVM); }
public NewGameCMD(GameVM gameVM) { ID = "newgame"; Image = Icon.FromResource("Pulsar4X.CrossPlatformUI.Resources.Icons.NewGame.ico"); MenuText = "New Game"; ToolBarText = "New Game"; Shortcut = Keys.F11; _gameVM = gameVM; }
/// <summary> /// Creates and fills out the properties of this ViewModel from the provided entity. /// </summary> internal static PlanetVM Create(GameVM gameVM, Entity entity) { PlanetVM newVM = new PlanetVM(gameVM, entity); // Initialize the data. newVM.Refresh(); return(newVM); }
public SystemInfoVM(GameVM gameVM) { _gameVM = gameVM; StarSystems.SelectionChangedEvent += StarSystems_SelectionChangedEvent; Entities.SelectionChangedEvent += Entities_SelectionChangedEvent; TreeBlobs.SelectionChangedEvent += TreeBlobs_SelectionChangedEvent; PopulateStarSystemList(); }
//public Dictionary<IDrawIconMethod, List<AIconData<BaseDataBlob>>> IconsDictionary = new Dictionary<IDrawIconMethod, List<AIconData<BaseDataBlob>>>(); public void InitializeForGM(GameVM gameVM, StarSystem starSys) { _changeListner = new EntityChangeListnerSM(starSys); foreach (var entityWithPosition in starSys.GetAllEntitiesWithDataBlob <PositionDB>()) { AddIconableEntity(entityWithPosition); _changeListner.ListningToEntites.Add(entityWithPosition); } }
Entity CreateNewSpecies(GameVM gameVM) { NameDB name = new NameDB(Name); SpeciesDB species = new SpeciesDB(BaseGravity.Value, MinGravity.Value, MaxGravity.Value, BasePressure.Value, MinPressure.Value, MaxPressure.Value, BaseTemprature.Value, MinTemprature.Value, MaxTemprature.Value); return(SpeciesFactory.CreateSpeciesFromBlobs(gameVM.CurrentFaction, gameVM.Game.GlobalManager, name, species)); }
/// <summary> /// Creates and fills out the properties of this ViewModel from the provided entity. /// </summary> public static StarVM Create(GameVM gameVM, Entity entity, SystemVM systemVM) { StarVM newVM = new StarVM(gameVM, entity); // Initialize the data. newVM.Init(systemVM); newVM.Refresh(); return(newVM); }
public PlayerOptionsVM(GameVM gameVM) { _gameVM = gameVM; Players.Add(_gameVM.Game.SpaceMaster, _gameVM.Game.SpaceMaster.Name); foreach (var player in gameVM.Game.Players) { Players.Add(player, player.Name); } Players.SelectedIndex = 0; Players.SelectionChangedEvent += Factions_SelectionChangedEvent; }
public SaveGame(GameVM gameVM) { _gameVM = gameVM; ID = "savegame"; Image = Icon.FromResource("Pulsar4X.CrossPlatformUI.Resources.Icons.NewGame.ico"); MenuText = "Save Game"; ToolBarText = "Save Game"; Shortcut = Keys.F6; Enabled = _gameVM.HasGame; _gameVM.PropertyChanged += GameVMPropertyChanged; }
//private int viewport_width; //private int viewport_height; public StarSystemSelectionVM(GameVM gameVM, Game game, Entity factionEntity) { _gameVM = gameVM; foreach (var item in game.GetSystems(gameVM.CurrentAuthToken)) { StarSystems.Add(item, item.NameDB.GetName(factionEntity)); } StarSystems.SelectedIndex = 0; StarSystems.SelectionChangedEvent += StarSystems_SelectionChangedEvent; StarSystems.DisplayList.CollectionChanged += DisplayList_CollectionChanged; //_gameVM.StarSystems.CollectionChanged += StarSystems_CollectionChanged; }
public void Initialise(GameVM gameVM) { _gameVM = gameVM; _timeloop = gameVM.Game.GamePulse; OnPropertyChanged(nameof(TickLength)); OnPropertyChanged(nameof(TickMultiplier)); OnPropertyChanged(nameof(TickFreq)); OnPropertyChanged(nameof(CurrentGameDate)); _timeloop.GameGlobalDateChangedEvent += OnTimeDateChange; }
/// <summary> /// Constructor for empty VM /// </summary> /// <param name="parent"></param> /// <param name="gameVM"></param> public ComponentTemplateMainPropertiesVM(ComponentTemplateParentVM parent, GameVM gameVM) : base(parent) { _staticData = gameVM.Game.StaticData; SubControlInFocus = FocusedControl.MassControl; foreach (var item in Enum.GetValues(typeof(ComponentMountType))) { if ((ComponentMountType)item != ComponentMountType.None) { MountType.Add((ComponentMountType)item, false); } } }
public NewGameOptionsVM(GameVM gameVM) { _gameVM = gameVM; CreatePlayerFaction = true; DefaultStart = true; FactionName = "United Earth Federation"; FactionPassword = ""; GmPassword = ""; NumberOfSystems = 50; AvailableModList = new ObservableCollection <DataVersionInfo>(StaticDataManager.AvailableData()); SelectedModList = new ObservableCollection <DataVersionInfo>(); }
public ComponentDesignVM(GameVM gameVM) { _gameVM = gameVM; _staticData = gameVM.Game.StaticData; _factionEntity = gameVM.CurrentFaction; _factionTech = gameVM.CurrentFaction.GetDataBlob <FactionTechDB>(); foreach (var componentSD in gameVM.Game.StaticData.ComponentTemplates.Values) { ComponentTypes.Add(componentSD.Name, componentSD.ID); } ComponentTypes.SelectedIndex = 0; }
/// <summary> /// Constructor /// </summary> /// <param name="gameVM"></param> public ComponentTemplateParentVM(GameVM gameVM) { _staticData = gameVM.Game.StaticData; _gameVM = gameVM; FormulaEditor = new FormulaEditorVM(this, _staticData); foreach (var item in _staticData.ComponentTemplates.Values) { Components.Add(item, item.Name); } SelectedComponent = new ComponentTemplateMainPropertiesVM(this, _gameVM); Components.SelectionChangedEvent += Components_SelectionChangedEvent; Components.SelectedIndex = 0; }
/// <summary> /// Creates and fills out the properties of this ViewModel from the entity with the provided ID. /// </summary> /// <exception cref="InvalidOperationException">Cannot create a Planet ViewModel without an initialized game.</exception> /// <exception cref="GuidNotFoundException">Thrown when the supplied ID is not found in the game.</exception> internal static StarVM Create(GameVM gameVM, Guid guid, SystemVM systemVM) { if (gameVM.Game == null) { throw new InvalidOperationException("Cannot create a StarVM without an initialized game."); } Entity entity; if (!gameVM.Game.GlobalManager.FindEntityByGuid(guid, out entity)) { throw new GuidNotFoundException(guid); } return(Create(gameVM, entity, systemVM)); }
private SystemVM(GameVM gameVM, StarSystem starSystem) { _gameVM = gameVM; _name = starSystem.NameDB.DefaultName; StarSystem = starSystem; _stars = new BindingList <StarVM>(); _planets = new BindingList <PlanetVM>(); _starDictionary = new Dictionary <Guid, StarVM>(); _planetDictionary = new Dictionary <Guid, PlanetVM>(); //find most massive star, this is the parent. Entity parentStar = starSystem.GetFirstEntityWithDataBlob <StarInfoDB>(gameVM.CurrentAuthToken); StarVM parentstarVM = StarVM.Create(_gameVM, parentStar, this); foreach (var star in starSystem.GetAllEntitiesWithDataBlob <StarInfoDB>(gameVM.CurrentAuthToken)) { StarVM starVM = StarVM.Create(_gameVM, star, this); if (!_stars.Contains(starVM)) { _stars.Add(starVM); } if (!_starDictionary.ContainsKey(star.Guid)) { _starDictionary.Add(star.Guid, starVM); } if (star.GetDataBlob <MassVolumeDB>().Mass > parentStar.GetDataBlob <MassVolumeDB>().Mass) { parentStar = star; parentstarVM = starVM; } } _parentStar = parentstarVM; ID = _parentStar.Entity.Guid; foreach (var planet in starSystem.GetAllEntitiesWithDataBlob <SystemBodyInfoDB>(gameVM.CurrentAuthToken)) { PlanetVM planetVM = PlanetVM.Create(_gameVM, planet, parentstarVM); if (!_planets.Contains(planetVM)) { _planets.Add(planetVM); } if (!_planetDictionary.ContainsKey(planet.Guid)) { _planetDictionary.Add(planet.Guid, planetVM); } } }
/// <summary> /// Creates and fills out the properties of this ViewModel from the entity with the provided ID. /// </summary> /// <exception cref="InvalidOperationException">Cannot create a Planet ViewModel without an initialized game.</exception> /// <exception cref="GuidNotFoundException">Thrown when the supplied ID is not found in the game.</exception> internal static SystemVM Create(GameVM gameVM, Guid starSystemGuid) { if (gameVM.Game == null) { throw new InvalidOperationException("Cannot create a StarVM without an initialized game."); } List <StarSystem> systems = gameVM.Game.GetSystems(gameVM.CurrentAuthToken); foreach (StarSystem system in systems) { if (system.Guid == starSystemGuid) { return(Create(gameVM, system)); } } throw new GuidNotFoundException(starSystemGuid); }
public LogViewerVM(GameVM gameVM) { _gameVM = gameVM; if (Game != null && Auth != null) { foreach (var item in StaticRefLib.EventLog.GetAllEvents(Auth)) { EventsDict.Add(new EventVM(item, _gameVM.CurrentFaction, _gameVM)); } } foreach (var kvp in gameVM.CurrentPlayer.HaltsOnEvent) { EventTypes.Add(new EventTypeBoolPair(gameVM.CurrentPlayer, kvp.Key)); } _gameVM.Game.GameLoop.GameGlobalDateChangedEvent += GameLoop_GameGlobalDateChangedEvent; }
/// <summary> /// Constructor for VM filled with componentSD /// </summary> /// <param name="parent"></param> /// <param name="gameData"></param> /// <param name="designSD"></param> public ComponentTemplateMainPropertiesVM(ComponentTemplateParentVM parent, GameVM gameData, ComponentTemplateSD designSD) : this(parent, gameData) { SetDesignSD(designSD); }
private StarVM(GameVM gameVM, Entity entity) { Entity = entity; _gameVM = gameVM; _name = entity.GetDataBlob <NameDB>().DefaultName; }
public void NewGame() { _gameVM = new GameVM(); //_newGameOptions = NewGameOptionsVM.Create(_gameVM); //Assert.DoesNotThrow(() => _gameVM.CreateGame(_newGameOptions)); }
/// < @todo add runis data. #endregion #region Functions #region Construction private PlanetVM(GameVM gameVM, Entity entity) { _gameVM = gameVM; Entity = entity; }