1 [
EntityEditorProps(
category:
"GameScripted/Campaign", description:
"Simple component for changing material of flags and signs.", color:
"0 0 255 255")]
4 [
Attribute(
"1", UIWidgets.CheckBox,
"Is Owner entity Flag Pole?",
"")]
5 protected bool m_bIsFlagPole;
7 [
Attribute(
"{9BE1341F99D33483}Assets/Props/Fabric/Flags/Data/Flag_1_2_EVERON.emat", UIWidgets.ResourcePickerThumbnail,
"Default material to be used.",
params:
"emat")]
8 protected ResourceName m_sDefaultMaterial;
10 [
Attribute(
"", UIWidgets.ResourcePickerThumbnail,
"Optional MLOD, if required.",
params:
"emat")]
11 protected ResourceName m_sDefaultMLOD;
22 ResourceName GetDefaultMaterial()
29 ResourceName GetDefaultMLOD()
36 class SCR_FlagComponent : SCR_MilitaryBaseLogicComponent
46 void ChangeMaterial(ResourceName flagResource, ResourceName resourceMLOD =
string.Empty)
52 SignalsManagerComponent signalsManager = SignalsManagerComponent.Cast(flag.FindComponent(SignalsManagerComponent));
54 if (flagResource.IsEmpty())
56 flag.ClearFlags(EntityFlags.VISIBLE);
59 signalsManager.SetSignalValue(signalsManager.AddOrFindSignal(
"IsNotVisible"), 1);
64 flag.SetFlags(EntityFlags.VISIBLE);
67 signalsManager.SetSignalValue(signalsManager.AddOrFindSignal(
"IsNotVisible"), 0);
70 VObject mesh = flag.GetVObject();
75 string materials[256];
76 int numMats = mesh.GetMaterials(materials);
78 for (
int i = 0; i < numMats; i++)
81 remap +=
string.Format(
"$remap '%1' '%2';", materials[i], resourceMLOD);
83 remap +=
string.Format(
"$remap '%1' '%2';", materials[i], flagResource);
86 flag.SetObject(mesh, remap);
94 if (prefabData && !prefabData.IsFlagPole())
97 SlotManagerComponent slotManager = SlotManagerComponent.Cast(
GetOwner().FindComponent(SlotManagerComponent));
101 array<EntitySlotInfo> slots = {};
102 slotManager.GetSlotInfos(slots);
106 IEntity flag = slot.GetAttachedEntity();
119 super.EOnInit(owner);
123 ChangeMaterial(prefabData.GetDefaultMaterial(), prefabData.GetDefaultMLOD());
129 super.OnPostInit(owner);
130 SetEventMask(owner, EntityEvent.INIT);