internal static PlanetVM Create(GameVM gameVM, Entity entity, StarVM parent_star) { var newvm = PlanetVM.Create(gameVM, entity); newvm.ParentStar = parent_star; return(newvm); }
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(); PlanetMineralDepositVM = new PlanetMineralDepositVM(staticData, _colonyEntity.GetDataBlob <ColonyInfoDB>().PlanetEntity); RefineryAbilityVM = new RefineryAbilityVM(staticData, _colonyEntity); ConstructionAbilityVM = new ConstructionAbilityVM(staticData, _colonyEntity); ColonyResearchVM = new ColonyResearchVM(staticData, _colonyEntity); }
public ShipOrderVM(GameVM game) { _gameVM = game; FactionInfoDB finfo = _gameVM.CurrentFaction.GetDataBlob <FactionInfoDB>(); foreach (SystemVM system in _gameVM.StarSystems) { if (finfo.KnownSystems.Contains(system.StarSystem.Guid)) { _starSystems.Add(system.StarSystem, system.StarSystem.NameDB.GetName(_gameVM.CurrentFaction)); } } _starSystems.SelectedIndex = 0; TargetShown = false; TargetAreaWidth = 2; RefreshShips(0, 0); //PropertyChanged += ShipOrderVM_PropertyChanged; SelectedSystem.SystemManager.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 static NewGameOptionsVM Create(GameVM gameVM) { NewGameOptionsVM optionsVM = new NewGameOptionsVM(); optionsVM._gameVM = gameVM; return(optionsVM); }
/// <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); }
/// <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 SystemInfoVM(GameVM gameVM) { _gameVM = gameVM; StarSystems.SelectionChangedEvent += StarSystems_SelectionChangedEvent; Entities.SelectionChangedEvent += Entities_SelectionChangedEvent; TreeBlobs.SelectionChangedEvent += TreeBlobs_SelectionChangedEvent; PopulateStarSystemList(); }
/// <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); }
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)); }
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 void Initialise(GameVM gameVM) { _gameVM = gameVM; _timeloop = gameVM.Game.GameLoop; 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); } } }
/// <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; }
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> /// Creates and fills out the properties of this ViewModel from the entity with the provided Guid. /// </summary> /// <exception cref="InvalidOperationException">Cannot create a Planet ViewModel without an initialized game.</exception> /// <exception cref="GuidNotFoundException">Thrown when the supplied Guid is not found in the game.</exception> internal static PlanetVM Create(GameVM gameVM, Guid guid) { if (gameVM.Game == null) { throw new InvalidOperationException("Cannot create a PlanetVM without an initialized game."); } Entity entity; if (!gameVM.Game.GlobalManager.FindEntityByGuid(guid, out entity)) { throw new GuidNotFoundException(guid); } return(Create(gameVM, entity)); }
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.SystemManager.GetFirstEntityWithDataBlob <StarInfoDB>(gameVM.CurrentAuthToken); StarVM parentstarVM = StarVM.Create(_gameVM, parentStar, this); foreach (var star in starSystem.SystemManager.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.SystemManager.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 Guid. /// </summary> /// <exception cref="InvalidOperationException">Cannot create a Planet ViewModel without an initialized game.</exception> /// <exception cref="GuidNotFoundException">Thrown when the supplied Guid 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 Game.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; }
public CargoItemVM(GameVM gameVM, CargoStorageDB storageDB, ICargoable item) { ItemID = item.ID; ItemName = item.Name; _storageDB = storageDB; ItemWeight = item.Mass; _storageDB.OwningEntity.Manager.ManagerSubpulses.SystemDateChangedEvent += ManagerSubpulses_SystemDateChangedEvent; if (item is MineralSD) { ItemTypeName = "Raw Mineral"; } else if (item is ProcessedMaterialSD) { ItemTypeName = "Processed Material"; } else if (item is CargoAbleTypeDB) { CargoAbleTypeDB itemdb = (CargoAbleTypeDB)item; Entity itemEntity = itemdb.OwningEntity; ItemTypeName = itemEntity.GetDataBlob <ComponentInstanceInfoDB>()?. DesignEntity.GetDataBlob <NameDB>().GetName(itemEntity.GetDataBlob <OwnedDB>(). ObjectOwner) ?? "Unknown Construct Type"; } }
public EventVM(Event evnt, Entity Faction, GameVM gameVM) { _evnt = evnt; _faction = Faction; _gameVM = gameVM; }
private StarVM(GameVM gameVM, Entity entity) { Entity = entity; _gameVM = gameVM; _name = entity.GetDataBlob <NameDB>().DefaultName; }
public static ShipOrderVM Create(GameVM game) { return(new ShipOrderVM(game)); }
public static ComponentDesignVM Create(GameVM gameVM) { return(new ComponentDesignVM(gameVM)); }
/// < @todo add runis data. #endregion #region Functions #region Construction private PlanetVM(GameVM gameVM, Entity entity) { _gameVM = gameVM; Entity = entity; }
/// <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); }
public CargoStorageByTypeVM(GameVM gameVM) { _gameVM = gameVM; _dataStore = _gameVM.Game.StaticData; }
public static ShipDesignVM Create(GameVM game) { return(new ShipDesignVM(game.CurrentFaction)); }