4 protected const float VEHICLE_RESOURCE_LIFETIME_PERCENTAGE = 0.25;
7 override protected float OnInsertRequested(IEntity entity,
float lifetime)
10 if (Vehicle.Cast(entity))
13 if (container && (container.GetMaxResourceValue() > 0))
15 if ((container.GetResourceValue() / container.GetMaxResourceValue()) > VEHICLE_RESOURCE_LIFETIME_PERCENTAGE)
21 container.GetOnResourcesChanged().Insert(HandleVehicleResourcesChanged);
32 float max = container.GetMaxResourceValue();
33 if ((max > 0) && ((container.GetResourceValue() / max) > VEHICLE_RESOURCE_LIFETIME_PERCENTAGE))
35 container.GetOnResourcesChanged().Remove(HandleVehicleResourcesChanged);
36 IEntity vehicle = container.GetOwner().GetRootParent();
37 Bump(vehicle, GetLifetime(vehicle));
44 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.Cast(entity.FindComponent(SCR_ResourceComponent));
45 if (!resourceComponent)
47 SlotManagerComponent slotManager = SlotManagerComponent.Cast(entity.FindComponent(SlotManagerComponent));
55 entity = slot.GetAttachedEntity();
59 resourceComponent = SCR_ResourceComponent.Cast(entity.FindComponent(SCR_ResourceComponent));
62 if (!resourceComponent)
65 return resourceComponent.GetContainer(resourceType);