Example #1
0
 public override void OnInspectorGUI()
 {
     base.OnInspectorGUI();
     if (GUILayout.Button("Get Values"))
     {
         ((StreamingTest)target).settings = ServerVariables.GetPlayerMovementValues();
     }
 }
Example #2
0
    protected override void OnUpdate()
    {
        EntityManager entityManager = EntityManager;

        Entities.WithStructuralChanges().WithNone <SendRpcCommandRequestComponent>().ForEach((Entity reqEnt, ref GoInGameRequest req, ref ReceiveRpcCommandRequestComponent reqSrc) =>
        {
            entityManager.AddComponent <NetworkStreamInGame>(reqSrc.SourceConnection);
            UnityEngine.Debug.Log(System.String.Format("Server setting connection {0} to in game", EntityManager.GetComponentData <NetworkIdComponent>(reqSrc.SourceConnection).Value));
            var ghostCollection = GetSingleton <GhostPrefabCollectionComponent>();


            var ghostId = PlayersGhostSerializerCollection.FindGhostType <PilotSnapshotData>();
            var prefab  = EntityManager.GetBuffer <GhostPrefabBuffer>(ghostCollection.serverPrefabs)[ghostId].Value;
            var player  = entityManager.Instantiate(prefab);
            entityManager.SetComponentData(player, new PilotData {
                PlayerId = EntityManager.GetComponentData <NetworkIdComponent>(reqSrc.SourceConnection).Value
            });
            entityManager.AddBuffer <PilotInput>(player);

            entityManager.SetComponentData(reqSrc.SourceConnection, new CommandTargetComponent {
                targetEntity = player
            });

            entityManager.DestroyEntity(reqEnt);
            Debug.Log("Spawend Player");

            var command = entityManager.CreateEntity();
            entityManager.AddComponent <SetServerVars>(command);
            ServerVariables.pilotSettings = ServerVariables.GetPlayerMovementValues();
            entityManager.SetComponentData(command, new SetServerVars {
                pilotSettings = ServerVariables.pilotSettings.ToFloatArray()
            });
            entityManager.AddComponent <SendRpcCommandRequestComponent>(command);
            entityManager.SetComponentData(command, new SendRpcCommandRequestComponent {
                TargetConnection = reqSrc.SourceConnection
            });
        }).Run();
    }