/// <summary> /// Create a personlaity based on a pesonality or if the personality is null pick a new personality /// </summary> /// <param name="personality"></param> public void CreateCharacterItem(TileConfiguration tileConfiguration) { // Instantiate a character prefab GameObject newChar = Instantiate(characterPrefab) as GameObject; #if UNITY_EDITOR int cloneNumber = 0; string name = "Character"; while (GameObject.Find(name + cloneNumber.ToString()) != null) { cloneNumber++; } newChar.name = name + cloneNumber.ToString(); #endif // Get Character Component Character character = newChar.GetComponent <Character>(); // Add the Character component to the characters list characters.Add(character.personality); // If the method was call with a null personality pick a new personality character.personality.SetupPersonality(PersonalityManager.PersonalityModel, tileConfiguration.personalityIndex); // Modify Character character.personality.TraitsEffect(); // Do the first movement to a free tile position character.snapCharacter.DoMovement(GridManager.Instance.Grid.GridToWorldFixed(tileConfiguration.position), false); // Child to Character holder newChar.transform.SetParent(characterPlaceholder); }
public override bool TryResolveAltInteractVerb(Entity entity, EntityUniverseFacade facade, Vector3I location, TileConfiguration lookedAtTile, out string verb) { verb = "nimbusfox.powerapi.verb.changeMode"; return(false); }
public override bool TryResolveMainInteractVerb(Entity entity, EntityUniverseFacade facade, Vector3I location, TileConfiguration lookedAtTile, out string verb) { verb = facade.AnyInnerCableEntitiesInTile(location, out _) ? "nimbusfox.powerapi.verb.extract" : "nimbusfox.powerapi.verb.insert"; return(true); }
protected override void Seed(NoDaysOffAppContext context) { TenantConfiguration.Seed(context); DashboardConfiguration.Seed(context); DayConfiguration.Seed(context); TileConfiguration.Seed(context); BoundedContextConfiguration.Seed(context); }
protected override void Seed(BacklogContext context) { TenantConfiguration.Seed(context); RoleConfiguration.Seed(context); UserConfiguration.Seed(context); TaskStatusConfiguration.Seed(context); ProfileConfiguration.Seed(context); TileConfiguration.Seed(context); }
public override void UpdateWithData(Blob blob) { _logicOwner = blob.GetLong("owner", 0L); if (_logicOwner == EntityId.NullEntityId) { return; } Configuration = GameContext.TileDatabase.GetTileConfiguration(blob.GetString("tile")); }
/// <summary> /// Called whenever the tile entity is created. Setup time! /// </summary> /// <param name="arguments"></param> /// <param name="entityUniverseFacade"></param> public override void Construct(Blob arguments, EntityUniverseFacade entityUniverseFacade) { this._configuration = GameContext.TileDatabase.GetTileConfiguration(arguments.GetString("tile")); this._signComponent = _configuration.Components.GetOrDefault <SignComponent>(); this.Location = arguments.FetchBlob("location").GetVector3I(); this._variant = (uint)arguments.GetLong("variant"); this.Entity.Physics.Construct(arguments.FetchBlob("position").GetVector3D(), Vector3D.Zero); this.Entity.Physics.MakePhysicsless(); }
public void AddTilePosition(Vector2 position, int personalityIndex) { if (tilesPosition == null) { tilesPosition = new List <TileConfiguration>(); } TileConfiguration tile = new TileConfiguration(position, personalityIndex); tilesPosition.Add(tile); }
public RadiusGenerator(TileConfiguration tileConfiguration, MapConfig mapConfig) { config = tileConfiguration; mConfig = mapConfig; grid = new int[mConfig.maxRadius * 2 + mConfig.maxRoomWidth, mConfig.maxRadius * 2 + mConfig.maxRoomHeight]; gridCopy = new int[mConfig.maxRadius * 2 + mConfig.maxRoomWidth, mConfig.maxRadius * 2 + mConfig.maxRoomHeight]; gridCopy = grid.Clone() as int[, ]; }
public override void Construct(Blob arguments, EntityUniverseFacade entityUniverseFacade) { _despawn = arguments.GetBool("despawn", false); Location = arguments.FetchBlob("location").GetVector3I(); Configuration = GameContext.TileDatabase.GetTileConfiguration(arguments.GetString("tile")); if (_logicOwner == EntityId.NullEntityId) { var blob = BlobAllocator.Blob(true); blob.SetString("tile", Configuration.Code); blob.FetchBlob("location").SetVector3I(Location); blob.SetBool("ignoreSpawn", _despawn); var entities = new Lyst <Entity>(); entityUniverseFacade.FindAllEntitiesInRange(entities, Location.ToVector3D(), 1F, entity => { if (entity.Removed) { return(false); } if (entity.Logic is GeneratorTileEntityLogic logic) { return(Location == logic.Location); } return(false); }); var tileEntity = entities.FirstOrDefault(); if (tileEntity != default(Entity)) { _logicOwner = tileEntity.Id; } else { var components = Configuration.Components.Select <GeneratorComponent>().ToList(); if (components.Any()) { var component = components.First(); if (component.Type == "solar") { _logicOwner = ChargeableTileEntityBuilder.Spawn(Location, blob, entityUniverseFacade, SolarPanelTileEntityBuilder.KindCode).Id; } else if (component.Type == "waterMill") { _logicOwner = ChargeableTileEntityBuilder.Spawn(Location, blob, entityUniverseFacade, WaterMillTileEntityBuilder.KindCode).Id; } } } } }
public override void Restore() { base.Restore(); Location = _blob.FetchBlob("location").GetVector3I(); _variant = (uint)_blob.GetLong("variant"); _done = _blob.GetBool("done"); _configuration = GameContext.TileDatabase.GetTileConfiguration(_blob.GetString("tile")); Component = _configuration.Components.Get <CenterComponentBuilder.CenterTotemComponent>(); _ballSpawned = _blob.GetBool("ballSpawned", true); RoundStartedTimestep = _blob.GetTimestep("roundStartedTimestep", Timestep.Null); }
public RenderTileLayer(TileLayer <Tile> tileLayer, TileConfiguration tileConfiguration) { TileLayer = tileLayer; _tileConfiguration = tileConfiguration; _renderTiles = new List <RenderTile>(); Plot(); TileLayer.TileAdded += OnTileAdded; TileLayer.TileRemoved += OnTileRemoved; }
public override void Construct(Blob arguments, EntityUniverseFacade entityUniverseFacade) { _configuration = GameContext.TileDatabase.GetTileConfiguration(arguments.GetString("tile")); Component = _configuration.Components.GetOrDefault <CenterComponentBuilder.CenterTotemComponent>(); Location = arguments.FetchBlob("location").GetVector3I(); _variant = (uint)arguments.GetLong("variant"); Entity.Physics.Construct(arguments.FetchBlob("position").GetVector3D(), Vector3D.Zero); Entity.Physics.MakePhysicsless(); _ballSpawned = true; _ball = GameContext.ItemDatabase.SpawnItem(Component.SoccerBall, null); }
public override void Restore() { base.Restore(); Location = _blob.FetchBlob("location").GetVector3I(); _variant = (uint)_blob.GetLong("variant"); _done = _blob.GetBool("done"); _countPosition = _blob.GetBlob("countPosition").GetVector3D(); _boundingShape = Shape.FromBlob(_blob.FetchBlob("boundingShape")); _configuration = GameContext.TileDatabase.GetTileConfiguration(_blob.GetString("tile")); _goalComponent = _configuration.Components.Get <SoccerGoalComponentBuilder.GoalComponent>(); GoalCount = (int)_blob.GetLong("goalCount", 0); }
public TileConfiguration GetNextCharacterTile() { foreach (KeyValuePair <Vector3, int> tile in TilesPosition) { if (tile.Value != -1) { TileConfiguration tileConf = new TileConfiguration(tile.Key, tile.Value); TilesPosition[tile.Key] = -1; return(tileConf); } } return(null); }
public override void Construct(Blob arguments, EntityUniverseFacade entityUniverseFacade) { _configuration = GameContext.TileDatabase.GetTileConfiguration(arguments.GetString("tile")); _goalComponent = _configuration.Components.GetOrDefault <SoccerGoalComponentBuilder.GoalComponent>(); var tile = _configuration.MakeTile(); Vector3D ignored; _boundingShape = tile.Configuration.FetchBoundingBox(tile.Variant(), out ignored).ToShape().Scale(_goalComponent == null ? 1f : _goalComponent.HitBoxScale); Location = arguments.FetchBlob("location").GetVector3I(); _variant = (uint)arguments.GetLong("variant"); Entity.Physics.Construct(arguments.FetchBlob("position").GetVector3D(), Vector3D.Zero); Entity.Physics.MakePhysicsless(); }
public void LoadTiles() { var configFileName = Path.Combine( new StorageFile(_resourceManager.LocalDataFolder.RelativePathParts.Merge(_sourceDirectoryRelativePath)).LocalPath, ConfigFileName); if (!File.Exists(configFileName)) { return; } Tiles = TileConfiguration.FromFile(configFileName); }
protected override void ParseElementConditions(XElement elemtype, TileConfiguration <T> .Content content) { var elemItems = elemtype.Elements("item"); foreach (XElement elemItem in elemItems) { XAttribute elemToken = elemItem.Attribute("token"); if (elemToken != null) { itemMatcher[elemToken.Value] = content; } } }
public override void Restore() { int num = (int)_blob.GetLong("revision", -1L); if (num == _revision) { return; } _revision = num; base.Restore(); _done = _blob.GetBool("done"); _configuration = GameContext.TileDatabase.GetTileConfiguration(_blob.GetString("tile")); Location = _blob.FetchBlob("location").GetVector3I(); }
public override void Construct(Blob arguments, EntityUniverseFacade entityUniverseFacade) { Location = arguments.FetchBlob("location").GetVector3I(); Configuration = GameContext.TileDatabase.GetTileConfiguration(arguments.GetString("tile")); if (_logicOwner == EntityId.NullEntityId) { if (Configuration.Components.Contains <SwitchTileComponent>()) { var components = Configuration.Components.Get <SwitchTileComponent>(); On = GameContext.TileDatabase.GetTileConfiguration(components.On); Off = GameContext.TileDatabase.GetTileConfiguration(components.Off); } var blob = BlobAllocator.Blob(true); blob.SetString("tile", Configuration.Code); blob.FetchBlob("location").SetVector3I(Location); var entities = new Lyst <Entity>(); entityUniverseFacade.FindAllEntitiesInRange(entities, Location.ToVector3D(), 1F, entity => { if (entity.Removed) { return(false); } if (entity.Logic is SwitchTileEntityLogic logic) { return(Location == logic.Location); } return(false); }); var tileEntity = entities.FirstOrDefault(); if (tileEntity != default(Entity)) { _logicOwner = tileEntity.Id; } else { _logicOwner = SwitchTileEntityBuilder.Spawn(Location, blob, entityUniverseFacade).Id; } } }
public static Item MakeItem(this TileConfiguration tile, string kind = "staxel.item.placer") { var itemBlob = BlobAllocator.Blob(true); itemBlob.SetString("kind", kind); itemBlob.SetString("tile", tile.Code); var item = GameContext.ItemDatabase.SpawnItemStack(itemBlob, null); Blob.Deallocate(ref itemBlob); if (item.IsNull()) { return(Item.NullItem); } return(item.Item); }
public override bool TryResolveMainInteractVerb(Entity entity, EntityUniverseFacade facade, Vector3I location, TileConfiguration lookedAtTile, out string verb) { if (lookedAtTile.Components.Contains <WrenchableComponent>()) { verb = GetVerb(); return(true); } else { if (_mode == Mode.Rotate) { verb = "nimbusfox.powerapi.verb.rotate"; return(true); } } return(base.TryResolveMainInteractVerb(entity, facade, location, lookedAtTile, out verb)); }
public override void PostUpdate(Timestep timestep, EntityUniverseFacade universe) { Tile result; if (!universe.ReadTile(Location, TileAccessFlags.None, out result)) { return; } if (result.Configuration != _configuration) { if (result.Configuration.CanonicalConfiguration == _configuration.CanonicalConfiguration) { _configuration = result.Configuration; _needsStore = true; } else { universe.RemoveEntity(Entity.Id); } } }
/// <summary> /// Restore entity from temp save data /// </summary> public override void Restore() { base.Restore(); this.Location = base._blob.FetchBlob("location").GetVector3I(); this._variant = (uint)base._blob.GetLong("variant"); this._configuration = GameContext.TileDatabase.GetTileConfiguration(base._blob.GetString("tile")); this._centerPos = base._blob.GetBlob("centerPos").GetVector3D(); this._isRemoved = base._blob.GetBool("isRemoved"); this._message = base._blob.GetString("message"); this._color = new Color() { PackedValue = (uint)base._blob.GetLong("color") }; this._scale = (float)base._blob.GetDouble("scale"); this._align = (BmFontAlign)base._blob.GetLong("align"); this._signComponent = _configuration.Components.GetOrDefault <SignComponent>(); }
public static ContentConfiguration <T> GetFromRootElement(XElement elemRoot, XName name) { ContentConfiguration <T> output; if (elemRoot.Element(name).Elements().Count() == 0) { output = new MaterialConfiguration <T>(); output.nodeName = name.LocalName; return(output); } switch (elemRoot.Element(name).Elements().First().Name.LocalName) { case "material": output = new MaterialConfiguration <T>(); break; case "tiletype": output = new TileConfiguration <T>(); break; case "random": output = new RandomConfiguration <T>(); break; case "ramp": output = new RampConfiguration <T>(); break; case "item": output = new ItemConfiguration <T>(); break; default: Debug.LogError("Found unknown matching method \"" + elemRoot.Element(name).Elements().First().Name.LocalName + "\", assuming material."); output = new MaterialConfiguration <T>(); break; } output.nodeName = name.LocalName; return(output); }
protected override void ParseElementConditions(XElement elemtype, TileConfiguration <T> .Content content) { var elemRamps = elemtype.Elements("ramp"); foreach (XElement elemRamp in elemRamps) { XAttribute indexAttr = elemRamp.Attribute("index"); if (indexAttr == null) { continue; } int index = 0; if (!int.TryParse(indexAttr.Value, out index)) { continue; } if (index > 26) { continue; } rampList[index - 1] = content; } }
bool ParseContentXMLFile(string path) { bool runningResult = true; XElement doc = XElement.Load(path, LoadOptions.SetBaseUri); while (doc != null) { switch (doc.Name.LocalName) { case "colors": if (ColorConfiguration == null) ColorConfiguration = TileConfiguration<ColorContent>.GetFromRootElement(doc, "color"); ColorConfiguration.AddSingleContentConfig(doc, null, materialColors); break; case "materialTextures": if (MaterialTextureConfiguration == null) MaterialTextureConfiguration = TileConfiguration<TextureContent>.GetFromRootElement(doc, "materialTexture"); MaterialTextureConfiguration.AddSingleContentConfig(doc, materialTextureStorage, materialTextures); break; case "shapeTextures": if(ShapeTextureConfiguration == null) ShapeTextureConfiguration = TileConfiguration<NormalContent>.GetFromRootElement(doc, "shapeTexture"); ShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage); break; case "tileMeshes": if (TileMeshConfiguration == null) TileMeshConfiguration = TileConfiguration<MeshContent>.GetFromRootElement(doc, "tileMesh"); TileMeshConfiguration.AddSingleContentConfig(doc, shapeTextureStorage); break; case "materialLayers": if (MaterialLayerConfiguration == null) MaterialLayerConfiguration = TileConfiguration<LayerContent>.GetFromRootElement(doc, "materialLayer"); MaterialLayerConfiguration.AddSingleContentConfig(doc); break; case "buildingMeshes": if (BuildingMeshConfiguration == null) BuildingMeshConfiguration = TileConfiguration<MeshContent>.GetFromRootElement(doc, "buildingMesh"); BuildingMeshConfiguration.AddSingleContentConfig(doc, shapeTextureStorage); break; case "buildingShapeTextures": if (BuildingShapeTextureConfiguration == null) BuildingShapeTextureConfiguration = TileConfiguration<NormalContent>.GetFromRootElement(doc, "buildingShapeTexture"); BuildingShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage); break; default: break; } doc = doc.NextNode as XElement; } return runningResult; }
public override void Construct(Blob arguments, EntityUniverseFacade entityUniverseFacade) { _configuration = !arguments.Contains("tileMapping") ? GameContext.TileDatabase.GetTileConfiguration(arguments.GetString("tile")) : GameContext.TileMapping[(int)arguments.GetLong("tileMapping")].V; Location = arguments.FetchBlob("location").GetVector3I(); Entity.Physics.Construct(arguments.FetchBlob("position").GetVector3D(), arguments.FetchBlob("velocity").GetVector3D()); }
public override bool TryResolveMainInteractVerb(Entity entity, EntityUniverseFacade facade, Vector3I location, TileConfiguration lookedAtTile, out string verb) { verb = InteractVerb(); return(true); }
public override bool TryResolveMainInteractVerb(Entity entity, EntityUniverseFacade facade, Vector3I location, TileConfiguration lookedAtTile, out string verb) { verb = "nimbusfox.worldedit.verb.pos1"; return(true); }
IEnumerator ParseContentXMLFile(string path) { Debug.Log("Loading XML File: " + path); XElement doc = XElement.Load(path, LoadOptions.SetBaseUri | LoadOptions.SetLineInfo); while (doc != null) { switch (doc.Name.LocalName) { case "colors": if (ColorConfiguration == null) ColorConfiguration = TileConfiguration<ColorContent>.GetFromRootElement(doc, "color"); ColorConfiguration.AddSingleContentConfig(doc, null, materialColors); break; case "materialTextures": if (MaterialTextureConfiguration == null) MaterialTextureConfiguration = TileConfiguration<TextureContent>.GetFromRootElement(doc, "materialTexture"); MaterialTextureConfiguration.AddSingleContentConfig(doc, materialTextureStorage, materialTextures); break; case "shapeTextures": if (ShapeTextureConfiguration == null) ShapeTextureConfiguration = TileConfiguration<NormalContent>.GetFromRootElement(doc, "shapeTexture"); ShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage); break; case "terrainTextures": if (TerrainShapeTextureConfiguration == null) TerrainShapeTextureConfiguration = TileConfiguration<NormalContent>.GetFromRootElement(doc, "terrainTexture"); TerrainShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage); break; case "tileMeshes": if (TileMeshConfiguration == null) TileMeshConfiguration = TileConfiguration<MeshContent>.GetFromRootElement(doc, "tileMesh"); TileMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; case "materialLayers": if (MaterialLayerConfiguration == null) MaterialLayerConfiguration = TileConfiguration<LayerContent>.GetFromRootElement(doc, "materialLayer"); MaterialLayerConfiguration.AddSingleContentConfig(doc); break; case "buildingMeshes": if (BuildingMeshConfiguration == null) BuildingMeshConfiguration = TileConfiguration<MeshContent>.GetFromRootElement(doc, "buildingMesh"); BuildingMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; case "buildingShapeTextures": if (BuildingShapeTextureConfiguration == null) BuildingShapeTextureConfiguration = TileConfiguration<NormalContent>.GetFromRootElement(doc, "buildingShapeTexture"); BuildingShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage); break; case "creatureMeshes": if (CreatureMeshConfiguration == null) CreatureMeshConfiguration = CreatureConfiguration<MeshContent>.GetFromRootElement(doc, "creatureMesh"); CreatureMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; case "growthMeshes": if (GrowthMeshConfiguration == null) GrowthMeshConfiguration = TileConfiguration<MeshContent>.GetFromRootElement(doc, "growthMesh"); GrowthMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; case "designationMeshes": if (DesignationMeshConfiguration == null) DesignationMeshConfiguration = TileConfiguration<MeshContent>.GetFromRootElement(doc, "designationMesh"); DesignationMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; case "collisionMeshes": if (CollisionMeshConfiguration == null) CollisionMeshConfiguration = TileConfiguration<MeshContent>.GetFromRootElement(doc, "collisionMesh"); CollisionMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; case "buildingCollisionMeshes": if (BuildingCollisionMeshConfiguration == null) BuildingCollisionMeshConfiguration = TileConfiguration<MeshContent>.GetFromRootElement(doc, "buildingCollisionMesh"); BuildingCollisionMeshConfiguration.AddSingleContentConfig(doc, new MeshContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage, specialTextureStorage)); break; case "itemMeshes": if (ItemMeshConfiguration == null) ItemMeshConfiguration = TileConfiguration<MeshContent>.GetFromRootElement(doc, "itemMesh"); ItemMeshConfiguration.AddSingleContentConfig(doc, null); break; case "grassTextures": if (GrassTextureConfiguration == null) GrassTextureConfiguration = TileConfiguration<GrassContent>.GetFromRootElement(doc, "grassTexture"); GrassTextureConfiguration.AddSingleContentConfig(doc, new GrassContent.TextureStorageContainer(materialTextureStorage, shapeTextureStorage)); break; default: break; } doc = doc.NextNode as XElement; } yield return null; }
public object Instance(TileConfiguration tile, Blob config) { return(new CableComponent(config)); }