public static void AddStructure(Point position, string structureName, JEventBus eventBus = null)
        {
            StructureDefinition         structureDefinition         = new StructureDefinition(structureName, new Point(1, 1));
            Structure                   structure                   = new Structure(structureDefinition);
            AddStructureOnWorldMapEvent addStructureOnWorldMapEvent =
                new AddStructureOnWorldMapEvent(structure, position);

            BaseApi.SendEvent(eventBus, addStructureOnWorldMapEvent);
        }
Exemple #2
0
        public void CreateUrbanListener(CreateUrbanEvent createUrbanEvent)
        {
            Entity resource = entityWorld.CreateEntityFromTemplate("Urban",
                                                                   createUrbanEvent.Position, createUrbanEvent.Population, createUrbanEvent.BirdsRate);

            _urbans[createUrbanEvent.Position] = resource;

            Structure structure = new Structure(new StructureDefinition("City", new Point(1, 1)));
            AddStructureOnWorldMapEvent addStructureOnWorldMap = new AddStructureOnWorldMapEvent(structure, createUrbanEvent.Position);

            _eventBus.Post(addStructureOnWorldMap);
        }
        public static void AddHabitat(Point position, CreatureDefinition creatureDefinition, int production = 7, JEventBus eventBus = null)
        {
            string structureName = creatureDefinition.Name + "Habitat";
            StructureDefinition         structureDefinition         = new StructureDefinition(structureName, new Point(1, 1));
            Structure                   structure                   = new Structure(structureDefinition);
            AddStructureOnWorldMapEvent addStructureOnWorldMapEvent =
                new AddStructureOnWorldMapEvent(structure, position);

            addStructureOnWorldMapEvent.Params.Add("template", "Habitat");
            addStructureOnWorldMapEvent.Params.Add("production", production);
            addStructureOnWorldMapEvent.Params.Add("definition", creatureDefinition);
            BaseApi.SendEvent(eventBus, addStructureOnWorldMapEvent);
        }
        public static void AddMine(Point position, ResourceDefinition resourceDefinition, int production = 500, JEventBus eventBus = null)
        {
            string structureName = resourceDefinition.Name + "Mine";
            StructureDefinition         structureDefinition         = new StructureDefinition(structureName, new Point(1, 1));
            Structure                   structure                   = new Structure(structureDefinition);
            AddStructureOnWorldMapEvent addStructureOnWorldMapEvent =
                new AddStructureOnWorldMapEvent(structure, position);

            addStructureOnWorldMapEvent.Params.Add("template", "Mine");
            addStructureOnWorldMapEvent.Params.Add("production", production);
            addStructureOnWorldMapEvent.Params.Add("definition", resourceDefinition);
            BaseApi.SendEvent(eventBus, addStructureOnWorldMapEvent);
        }
Exemple #5
0
        private Entity CreateEntityBasedOnStructureType(AddStructureOnWorldMapEvent addStructureOnWorldMapEvent)
        {
            Structure structure = addStructureOnWorldMapEvent.Structure;
            Point     position  = addStructureOnWorldMapEvent.Position;

            string templateName = "Structure";

            if (addStructureOnWorldMapEvent.Params.ContainsKey("template"))
            {
                if (addStructureOnWorldMapEvent.Params["template"] is string readValue)
                {
                    templateName = readValue;
                }
            }

            return(entityWorld.CreateEntityFromTemplate(templateName,
                                                        structure, position, addStructureOnWorldMapEvent.Params));
        }
Exemple #6
0
        public void AddStructureListener(AddStructureOnWorldMapEvent addStructureOnWorldMapEvent)
        {
            IsFreeAreaEvent isFreeAreaEvent = new IsFreeAreaEvent(addStructureOnWorldMapEvent.Position,
                                                                  addStructureOnWorldMapEvent.Structure.Definition.Size);

            _eventBus.Post(isFreeAreaEvent);

            if (!isFreeAreaEvent.IsFree)
            {
                // Debug.WriteLine("Area is blocked! " + isFreeAreaEvent);
                return;
            }

            Entity structure = CreateEntityBasedOnStructureType(addStructureOnWorldMapEvent);

            AddEntrance(structure, addStructureOnWorldMapEvent.Position +
                        addStructureOnWorldMapEvent.Structure.Definition.EntranceOffset);
            PlaceObjectOnMapEvent placeObjectOnMapEvent = new PlaceObjectOnMapEvent(structure,
                                                                                    addStructureOnWorldMapEvent.Position, addStructureOnWorldMapEvent.Structure.Definition.Size);

            _eventBus.Post(placeObjectOnMapEvent);
        }