-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix/tp2squadmate locality issues (#26)
* renamed layout to reflect what it is * moved to rpc from local GM to server for teleporting other players * fixed review comments, moved static emptyTerrainAreaRadius and removed unnessecary function * added prefix to static variable
- Loading branch information
1 parent
4f2df21
commit 42ad23a
Showing
7 changed files
with
93 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ SCR_EditorActionList { | |
m_iOrder 200 | ||
m_bEnableShortcutLogics 0 | ||
m_bShowOnCooldownNotification 0 | ||
m_bIsServer 1 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
Scripts/Game/ODIN/Editor/Entities/SCR_EditorManagerEntity.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** @ingroup Editor_Entities | ||
*/ | ||
|
||
/*! | ||
The entity which enables all editor functionality for the player. | ||
- It's **created by SCR_EditorManagerCore** when a player connects. | ||
+ Every player receives one. | ||
- In multiplayer, the entity is **local to the player**. | ||
+ This is required to allow communication with server (see Replication for more details). | ||
+ Requires RplComonent to function. | ||
- This entity handles **only barebone editor functionality**, like access rules, or opening and closing. | ||
- Everything else, like camera or menu handling, must be on specialized editor modes (SCR_EditorModeEntity) and components (SCR_BaseEditorComponent)! | ||
- Editor can have a limitied state, influenced by its modes and checked by IsLimited() function: | ||
+ Editor is **limited** if all its modes are. | ||
+ If at least one mode is unlimited, the editor is **unlimited** as well. | ||
+ The state influences behavior of certain components, e.g., photo mode camera movement may be restricted if the editor is limited. | ||
+ As a rule of thumb, unlimited state means that player can ***cheat*** with the editor. | ||
- Default editor manager prefab is defined in SCR_EditorManagerCore (config is Configs/Core folder). | ||
*/ | ||
modded class SCR_EditorManagerEntity : SCR_EditorBaseEntity | ||
{ | ||
static int ODIN_emptyTerrainAreaRadius = 20; | ||
|
||
/*! | ||
Functions to tell the server to move an entity | ||
*/ | ||
void ODIN_TeleportEntityToPlayer(RplId sourceEntityId, RplId targetEntityId) | ||
{ | ||
Rpc(ODIN_Server_TeleportEntityToPlayer, sourceEntityId, targetEntityId); | ||
} | ||
|
||
[RplRpc(RplChannel.Reliable, RplRcver.Server)] | ||
protected void ODIN_Server_TeleportEntityToPlayer(RplId entityId, RplId targetEntityId) | ||
{ | ||
// get entity from id | ||
RplComponent entityRpl = RplComponent.Cast(Replication.FindItem(entityId)); | ||
RplComponent targetRpl = RplComponent.Cast(Replication.FindItem(targetEntityId)); | ||
|
||
if (!entityRpl || !targetRpl) | ||
return; | ||
|
||
IEntity sourceEntity = entityRpl.GetEntity(); | ||
IEntity targetEntity = targetRpl.GetEntity(); | ||
|
||
if (!sourceEntity || !targetEntity) | ||
return; | ||
|
||
// If target is sitting in a vehicle, move player inside as well (Taken from SCR_PlayerSpawnPoint.c) | ||
SCR_CompartmentAccessComponent compartmentAccessTarget = SCR_CompartmentAccessComponent.Cast(targetEntity.FindComponent(SCR_CompartmentAccessComponent)); | ||
IEntity vehicle = compartmentAccessTarget.GetVehicle(); | ||
if (vehicle) | ||
{ | ||
SCR_CompartmentAccessComponent compartmentAccessPlayer = SCR_CompartmentAccessComponent.Cast(sourceEntity.FindComponent(SCR_CompartmentAccessComponent)); | ||
|
||
// if we succeed, we return to avoid teleporting the unit after having moved him into the vehicle. If we fail, we just continue and TP player next to vehicle | ||
if (compartmentAccessPlayer.MoveInVehicleAny(vehicle)) | ||
return; | ||
} | ||
|
||
// Get world coordinates of player | ||
vector target_pos; | ||
SCR_WorldTools.FindEmptyTerrainPosition(target_pos, targetEntity.GetOrigin(), ODIN_emptyTerrainAreaRadius); | ||
|
||
// get transform for rotation etc. | ||
vector target_transform[4]; | ||
sourceEntity.GetTransform(target_transform); | ||
|
||
// use new position, but keep rotation | ||
target_transform[3] = target_pos; | ||
|
||
// Get editable component | ||
SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(sourceEntity.FindComponent(SCR_EditableEntityComponent)); | ||
|
||
// call transform | ||
if (editableEntity) | ||
editableEntity.SetTransform(target_transform, true); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
//! Menu presets | ||
modded enum ChimeraMenuPreset | ||
{ | ||
ODIN_ListBox_ID, | ||
ODIN_Listbox_SingleSelect_ID, | ||
}; |
File renamed without changes.
File renamed without changes.