Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LIB_TownManagerComponentClass : ScriptComponentClass
- {
- };
- class LIB_TownData : Managed
- {
- EntityID markerID;
- string name;
- int population;
- int stability;
- int support;
- string faction;
- int size;
- }
- class LIB_TownManagerComponent : ScriptComponent
- {
- protected static ref array<IEntity> m_ObjArr = {};
- protected static ref array<IEntity> m_objMarkerArr = {};
- //------------------------------------------------------------------------------------------------
- override void EOnInit(IEntity owner)
- {
- //Print(owner.GetName());
- if (GetGame().InPlayMode()) {
- SCR_MapDescriptorComponent MapD = SCR_MapDescriptorComponent.Cast(owner.FindComponent(SCR_MapDescriptorComponent));
- if (IsObj(owner, MapD))
- {
- m_ObjArr.Insert(owner);
- IEntity MarkerEnt = CreateObjMarker(owner);
- CreateObjArea(owner);
- m_objMarkerArr.Insert(MarkerEnt);
- }
- }
- }
- bool IsObj(IEntity owner, SCR_MapDescriptorComponent MapD)
- {
- switch(MapD.GetBaseType())
- {
- case EMapDescriptorType.MDT_PORT:
- return true;
- break;
- case EMapDescriptorType.MDT_BASE:
- return true;
- break;
- case EMapDescriptorType.MDT_FORTRESS:
- return true;
- break;
- case EMapDescriptorType.MDT_FUELSTATION:
- return true;
- break;
- case EMapDescriptorType.MDT_NAME_GENERIC:
- return true;
- break;
- case EMapDescriptorType.MDT_NAME_CITY:
- return true;
- break;
- case EMapDescriptorType.MDT_NAME_VILLAGE:
- return true;
- break;
- case EMapDescriptorType.MDT_NAME_TOWN:
- return true;
- break;
- case EMapDescriptorType.MDT_NAME_SETTLEMENT:
- return true;
- break;
- }
- return false;
- }
- //------------------------------------------------------------------------------------------------
- override void OnPostInit(IEntity owner)
- {
- // remove if unused
- SetEventMask(owner, EntityEvent.INIT);
- }
- //------------------------------------------------------------------------------------------------
- override void OnDelete(IEntity owner)
- {
- // remove if unused
- SCR_MapDescriptorComponent MapD = SCR_MapDescriptorComponent.Cast(owner.FindComponent(SCR_MapDescriptorComponent));
- if (m_ObjArr) {
- m_ObjArr.RemoveItem(owner)
- }
- }
- //------------------------------------------------------------------------------------------------
- static IEntity GetRandObj()
- {
- if (m_ObjArr.IsEmpty()) {
- return null;
- };
- return m_ObjArr.GetRandomElement();
- }
- static array<IEntity> GetObjArr()
- {
- if (m_ObjArr.IsEmpty()) {
- return null;
- };
- return m_ObjArr;
- }
- IEntity CreateObjMarker(IEntity owner)
- {
- Print("Create Obj Marker");
- IEntity slotMarker = GetGame().SpawnEntityPrefab("{E537867C6E760514}Prefabs/ScenarioFramework/Components/Marker Entities/SlotMarker.et", false);
- LIB_ScenarioFrameworkSlotMarker markerComp = LIB_ScenarioFrameworkSlotMarker.Cast(slotMarker.FindComponent(LIB_ScenarioFrameworkSlotMarker));
- SCR_MapDescriptorComponent MapD = SCR_MapDescriptorComponent.Cast(owner.FindComponent(SCR_MapDescriptorComponent));
- slotMarker.SetOrigin(owner.GetOrigin());
- //Print(slotMarker);
- //Print(markerComp);
- markerComp.SetScriptSpawned(true);
- Print(MapD.GetBaseType());
- switch(MapD.GetBaseType())
- {
- case EMapDescriptorType.MDT_PORT:
- markerComp.SetMapMarkerIcon(LIB_EScenarioFrameworkMarkerCustom.FUELSTATION);
- PrintFormat("MDT_PORT: %1", LIB_EScenarioFrameworkMarkerCustom.FUELSTATION);
- break;
- case EMapDescriptorType.MDT_BASE:
- markerComp.SetMapMarkerIcon(LIB_EScenarioFrameworkMarkerCustom.MILITARY);
- PrintFormat("MDT_BASE: %1", LIB_EScenarioFrameworkMarkerCustom.MILITARY);
- break;
- case EMapDescriptorType.MDT_FORTRESS:
- markerComp.SetMapMarkerIcon(LIB_EScenarioFrameworkMarkerCustom.MILITARY);
- PrintFormat("MDT_FORTRESS: %1", LIB_EScenarioFrameworkMarkerCustom.MILITARY);
- break;
- case EMapDescriptorType.MDT_FUELSTATION:
- markerComp.SetMapMarkerIcon(LIB_EScenarioFrameworkMarkerCustom.FUELSTATION);
- PrintFormat("MDT_FUELSTATION: %1", LIB_EScenarioFrameworkMarkerCustom.FUELSTATION);
- break;
- case EMapDescriptorType.MDT_NAME_GENERIC:
- markerComp.SetMapMarkerIcon(LIB_EScenarioFrameworkMarkerCustom.TOWN);
- PrintFormat("MDT_NAME_GENERIC: %1", LIB_EScenarioFrameworkMarkerCustom.TOWN);
- break;
- case EMapDescriptorType.MDT_NAME_CITY:
- markerComp.SetMapMarkerIcon(LIB_EScenarioFrameworkMarkerCustom.CAPITAL);
- PrintFormat("MDT_NAME_CITY: %1", LIB_EScenarioFrameworkMarkerCustom.CAPITAL);
- break;
- case EMapDescriptorType.MDT_NAME_VILLAGE:
- markerComp.SetMapMarkerIcon(LIB_EScenarioFrameworkMarkerCustom.TOWN);
- PrintFormat("MDT_NAME_VILLAGE: %1", LIB_EScenarioFrameworkMarkerCustom.TOWN);
- break;
- case EMapDescriptorType.MDT_NAME_TOWN:
- markerComp.SetMapMarkerIcon(LIB_EScenarioFrameworkMarkerCustom.TOWN);
- PrintFormat("MDT_NAME_TOWN: %1", LIB_EScenarioFrameworkMarkerCustom.TOWN);
- break;
- case EMapDescriptorType.MDT_NAME_SETTLEMENT:
- markerComp.SetMapMarkerIcon(LIB_EScenarioFrameworkMarkerCustom.TOWN);
- PrintFormat("MDT_NAME_SETTLEMENT: %1", LIB_EScenarioFrameworkMarkerCustom.TOWN);
- break;
- }
- markerComp.SetMapMarkerColor(LIB_EScenarioFrameworkMarkerCustomColor.BLUFOR);
- markerComp.SetMapMarkerText(owner.GetName());
- markerComp.CreateMapMarker();
- return slotMarker;
- }
- // {C72F956E4AC6A6E7}Prefabs/ScenarioFramework/Components/Area.et
- void CreateObjArea(IEntity owner)
- {
- //IEntity Area = GetGame().SpawnEntityPrefab("{C72F956E4AC6A6E7}Prefabs/ScenarioFramework/Components/Area.et", false);
- //SCR_ScenarioFrameworkArea AreaComp = SCR_ScenarioFrameworkArea.Cast(Area.FindComponent(SCR_ScenarioFrameworkArea));
- //Area.SetOrigin(owner.GetOrigin());
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement