23 const SCR_ResourceComponent resource = SCR_ResourceComponent.Cast(component);
25 const BaseContainer source = component.GetComponentSource(owner);
26 auto containerSources = source.GetObjectArray(
"m_aContainers");
27 auto containers = resource.GetContainers();
29 array<ref SCR_PersistentResource> resources();
32 if (containerSources.Count() != containers.Count())
35 foreach (
int idx,
auto container : containers)
37 if (container.IsEncapsulated())
40 const EResourceType resourceType = container.GetResourceType();
41 if (!m_aResourceTypeFilter.IsEmpty() && !m_aResourceTypeFilter.Contains(resourceType))
44 const float value = container.GetResourceValue();
50 bool overrideByAction =
false;
52 foreach (
auto action : actions)
55 if (!changeDefaultAction)
58 overrideByAction =
true;
59 defaultValue = changeDefaultAction.GetValueCurrent();
62 if (!overrideByAction)
68 const SCR_ResourceComponent childComponent = childContainer.GetComponent();
69 const int containerIdx = childComponent.GetContainers().Find(childContainer);
70 auto childContainerSources = childComponent.GetComponentSource(childComponent.GetOwner()).GetObjectArray(
"m_aContainers");
71 if (containerIdx == -1 || containerIdx >= childContainerSources.Count())
74 float childDefaultValue;
75 childContainerSources.Get(containerIdx).Get(
"m_fResourceValueCurrent", childDefaultValue);
76 defaultValue += childDefaultValue;
82 containerSources.Get(
idx).Get(
"m_fResourceValueCurrent", defaultValue);
85 if (!
float.AlmostEqual(value, defaultValue))
88 entry.m_eResourceType = resourceType;
89 entry.m_fValue = value;
90 resources.Insert(entry);
95 array<EResourceType> disabledTypes();
96 resource.GetDisabledResourceTypes(disabledTypes);
98 array<EResourceType> disabledTypesDefault();
99 source.Get(
"m_aDisabledResourceTypes", disabledTypesDefault);
101 if (SCR_ArrayHelperT<EResourceType>.
AreEqual(disabledTypes, disabledTypesDefault))
102 disabledTypes = null;
104 if (resources.IsEmpty() && !disabledTypes)
107 context.WriteValue(
"version", 1);
109 if (!resources.IsEmpty() || !context.CanSeekMembers())
112 context.Write(resources);
113 context.EnableTypeDiscriminator(prev);
116 if (disabledTypes || !context.CanSeekMembers())
117 context.Write(disabledTypes);
125 SCR_ResourceComponent resource = SCR_ResourceComponent.Cast(component);
128 context.ReadValue(
"version", version);
131 array<ref SCR_PersistentResource> resources;
132 const bool resourcesRead = context.Read(resources);
133 context.EnableTypeDiscriminator(prev);
136 resource.Initialize(owner);
146 array<EResourceType> disabledTypes;
147 context.Read(disabledTypes);
151 array<EResourceType> currentDisabled();
152 resource.GetDisabledResourceTypes(currentDisabled);
155 if (!disabledTypes.Contains(
type))
156 resource.SetResourceTypeEnabled(
true,
type);
162 resource.SetResourceTypeEnabled(
false,
type);