public static Entity GetLocalSimPlayerEntity(ExternalSimWorldAccessor simulationWorld) { if (PlayerRepertoireSystem.Instance == null) { return(Entity.Null); } return(PlayerHelpers.GetSimPlayerFromPlayer(PlayerRepertoireSystem.Instance.GetLocalPlayerInfo(), simulationWorld)); }
public static PlayerInfo GetPlayerFromSimPlayer(Entity playerEntity, ExternalSimWorldAccessor simWorldAccessor) { if (simWorldAccessor.HasComponent <PersistentId>(playerEntity)) { return(GetPlayerFromSimPlayer(simWorldAccessor.GetComponent <PersistentId>(playerEntity))); } else { return(null); } }
public static Entity GetSimPlayerFromPlayer(PlayerInfo playerInfo, ExternalSimWorldAccessor simulationWorld) { Entity result = Entity.Null; simulationWorld.Entities .WithAllReadOnly <PlayerTag, PersistentId>() .ForEach((Entity playerEntity, ref PersistentId simPlayerId) => { if (simPlayerId == playerInfo.SimPlayerId) { result = playerEntity; return; } }); return(result); }
public static Entity GetLocalSimPawnEntity(ExternalSimWorldAccessor simulationWorld) { Entity localPlayerEntity = PlayerHelpers.GetLocalSimPlayerEntity(simulationWorld); // player is controlling an entity if (localPlayerEntity != Entity.Null && simulationWorld.TryGetComponent(localPlayerEntity, out ControlledEntity controlledEntity)) { // entity still exists and is controllable if (simulationWorld.Exists(controlledEntity.Value) && simulationWorld.HasComponent <Controllable>(controlledEntity.Value)) { return(controlledEntity.Value); } } return(Entity.Null); }
private void OnDrawGizmos() { ExternalSimWorldAccessor simWorld = PresentationHelpers.GetSimulationWorld(); if (simWorld == null || !simWorld.HasSingleton <GridInfo>()) { return; } GridInfo gridRect = simWorld.GetSingleton <GridInfo>(); Rect visualRect = new Rect(new Vector2(gridRect.TileMin.x, gridRect.TileMin.y), new Vector2(gridRect.Width, gridRect.Height)); Vector2 bottomLeft = visualRect.min; Vector2 bottomRight = new Vector2(visualRect.max.x, visualRect.min.y); Vector2 TopLeft = new Vector2(visualRect.min.x, visualRect.max.y); Vector2 TopRight = visualRect.max; Gizmos.color = Color; Gizmos.DrawLine(bottomLeft, bottomRight); Gizmos.DrawLine(bottomLeft, TopLeft); Gizmos.DrawLine(TopLeft, TopRight); Gizmos.DrawLine(TopRight, bottomRight); }