1 [
ComponentEditorProps(
category:
"GameScripted/Editor (Editables)", description:
"", icon:
"WBData/ComponentEditorProps/componentEditor.png")]
5 private ResourceName m_PrefabGroup;
9 ResourceName GetPrefabGroup()
43 if (rplComponent && rplComponent.Role() == RplRole.Authority)
102 EntitySpawnParams
params =
new EntitySpawnParams();
103 params.Transform[3] =
m_Agent.GetControlledEntity().GetOrigin();
104 IEntity groupEntity =
GetGame().SpawnEntityPrefab(Resource.Load(prefabData.GetPrefabGroup()), owner.GetWorld(),
params);
108 AIGroup group = AIGroup.Cast(groupEntity);
111 Print(
string.Format(
"Cannot create group, prefab '%1' is not AIGroup entity!", prefabData.GetPrefabGroup()), LogLevel.ERROR);
117 if (!groupEditableEntity)
119 Print(
string.Format(
"Cannot create group, prefab '%1' does not contain SCR_EditableEntityComponent!", prefabData.GetPrefabGroup()), LogLevel.ERROR);
128 FactionAffiliationComponent factionComponent = FactionAffiliationComponent.Cast(owner.FindComponent(FactionAffiliationComponent));
129 if (factionComponent)
131 Faction faction = factionComponent.GetAffiliatedFaction();
133 groupScripted.InitFactionKey(faction.GetFactionKey());
142 return groupEditableEntity;
152 return SCR_PossessingManagerComponent.GetPlayerIdFromMainEntity(owner) > 0;
154 return SCR_PossessingManagerComponent.GetPlayerIdFromMainEntity(
m_Owner) > 0;
167 RplComponent rplComp = RplComponent.Cast(
GetOwner().FindComponent(RplComponent));
168 return !rplComp || rplComp.IsOwner();
195 override bool Delete(
bool changedByUser =
false,
bool updateNavmesh =
true)
198 if (compartmentAccess)
200 BaseCompartmentSlot slot = compartmentAccess.GetCompartment();
202 slot.SetCompartmentAccessible(
true);
205 return super.Delete(changedByUser, updateNavmesh);
226 [
RplRpc(RplChannel.Reliable, RplRcver.Owner)]
229 super.SetTransformOwner(transform);
235 [
RplRpc(RplChannel.Reliable, RplRcver.Owner)]
242 if (!playerController)
245 if (
m_Owner != playerController.GetLocalControlledEntity())
248 SCR_PlayerTeleportedFeedbackComponent playerTeleportedComponent = SCR_PlayerTeleportedFeedbackComponent.Cast(playerController.FindComponent(SCR_PlayerTeleportedFeedbackComponent));
249 if (!playerTeleportedComponent)
270 if (world.IsGameTimePaused())
272 world.PauseGameTime(
false);
281 if (world.IsGameTimePaused() || !
GetOwner() || CompartmentAccessComponent.GetVehicleIn(
GetOwner()) == newParent)
283 world.PauseGameTime(
true);
294 AIControlComponent aiControl = AIControlComponent.Cast(
GetOwner().FindComponent(AIControlComponent));
295 if (aiControl && aiControl.IsAIActivated())
299 parentType = parentEntity.GetEntityType();
305 parentEntity.SetParentEntity(parentEntityPrev);
311 return super.SetParentEntity(parentEntity);
318 if (forceVehicleCompartments.IsEmpty())
334 parentType = parentEntity.GetEntityType();
345 if (Replication.IsServer())
348 Faction vehicleFaction = parentEntity.GetFaction();
350 if (vehicleFaction && characterFaction.IsFactionEnemy(vehicleFaction))
357 if (compartmentAccess)
370 if (!isAi && compartmentAccess.MoveInVehicle(parentOwner,
ECompartmentType.Pilot))
418 GetGame().GetCallqueue().CallLater(
Delete, param1:
false, param2:
true);
435 super.OnParentEntityChanged(group, parentEntityPrev, changedByUser);
442 super.OnParentEntityChanged(
null, parentEntityPrev, changedByUser);
455 override void SetTransform(vector transform[4],
bool changedByUser =
false)
458 CompartmentAccessComponent compartmentAccess = CompartmentAccessComponent.Cast(
GetOwner().FindComponent(CompartmentAccessComponent));
459 if (compartmentAccess && compartmentAccess.IsInCompartment())
470 compartmentAccess.MoveOutVehicle(-1, transform);
478 transform[3][1] = Math.Max(transform[3][1],
GetOwner().GetWorld().GetSurfaceY(transform[3][0], transform[3][2]));
480 super.SetTransform(transform, changedByUser);
489 return SCR_PossessingManagerComponent.GetPlayerIdFromMainEntity(
GetOwner());
506 Faction faction = factionManager.GetPlayerFaction(playerID);
512 FactionAffiliationComponent factionAffiliation = FactionAffiliationComponent.Cast(
m_Owner.FindComponent(FactionAffiliationComponent));
513 if (factionAffiliation)
514 return factionAffiliation.GetAffiliatedFaction();
528 return GetParentEntity();
541 if (compartmentAccess)
548 override int GetCrew(out notnull array<CompartmentAccessComponent> crewCompartmentAccess,
bool ignorePlayers =
true)
553 if (
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(
GetOwner()) > 0)
558 CompartmentAccessComponent compartmentAccess = CompartmentAccessComponent.Cast(
GetOwner().FindComponent(CompartmentAccessComponent));
559 if (compartmentAccess && compartmentAccess.IsInCompartment())
560 crewCompartmentAccess.Insert(compartmentAccess);
562 return crewCompartmentAccess.Count();
581 array<IEntity> usableVehicles = {};
582 aiGroup.GetUsableVehicles(usableVehicles);
584 if (!usableVehicles.Contains(vehicle))
585 aiGroup.AddUsableVehicle(vehicle);
606 array<IEntity> usableVehicles = {};
609 aiGroup.GetUsableVehicles(usableVehicles);
610 if (!usableVehicles.Contains(vehicle))
613 if (checkIfVehicleStillUsed)
615 set<SCR_EditableEntityComponent> entities =
new set<SCR_EditableEntityComponent>();
616 group.GetChildren(entities,
true);
618 SCR_EditableVehicleComponent editableVehicle = SCR_EditableVehicleComponent.Cast(vehicle.FindComponent(SCR_EditableVehicleComponent));
622 array<CompartmentAccessComponent> crewCompartmentAccess = {};
623 editableVehicle.GetCrew(crewCompartmentAccess,
true);
625 foreach (CompartmentAccessComponent compartment : crewCompartmentAccess)
629 if (crew ==
null || crew ==
this)
633 if (entities.Contains(crew) && !compartment.IsGettingOut())
640 aiGroup.RemoveUsableVehicle(vehicle);
669 bool isPlayerInVehicle = vehicle && playerId > 0;
679 return m_fMaxDrawDistance;
711 if (parent && AIGroup.Cast(parent.GetOwner()))
731 AIControlComponent control = AIControlComponent.Cast(
GetOwner().FindComponent(AIControlComponent));
733 control.ActivateAI();
740 if (!Replication.IsRunning() &&
IsPlayer())
743 if (super.Serialize(outTarget, outTargetIndex, outSaveFlags))
746 if (compartmentAccess)
763 BaseCompartmentManagerComponent compartmentManager = BaseCompartmentManagerComponent.Cast(target.GetOwner().FindComponent(BaseCompartmentManagerComponent));
764 array<BaseCompartmentSlot> compartments = {};
765 compartmentManager.GetCompartments(compartments);
768 compartmentAccess.MoveInVehicle(target.GetOwner(), compartments[targetValue]);
774 if (DiagMenu.GetValue(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_DISABLE))
777 super.OnPostInit(owner);
782 if (Replication.IsServer())
786 Print(
string.Format(
"SCR_EditableCharacterComponent must have type set to CHARACTER, it's %1!",
typename.EnumToString(
EEditableEntityType,
GetEntityType())), LogLevel.ERROR);
795 ChimeraCharacter
char = ChimeraCharacter.Cast(owner);
802 Print(
string.Format(
"Failed to insert listened for lifestate changing on SCR_EditableEntityComponent of: " +
GetOwner()), LogLevel.ERROR);
810 ChimeraCharacter
char = ChimeraCharacter.Cast(
GetOwner());