コード例 #1
0
 public static PlayerInfo GetPlayerFromSimPlayer(Entity playerEntity, ExternalSimWorldAccessor simWorldAccessor)
 {
     if (simWorldAccessor.HasComponent <PersistentId>(playerEntity))
     {
         return(GetPlayerFromSimPlayer(simWorldAccessor.GetComponent <PersistentId>(playerEntity)));
     }
     else
     {
         return(null);
     }
 }
コード例 #2
0
    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);
    }