Beispiel #1
0
    private static void CheatSetPawnDoodle(string imagePath)
    {
        if (!GamePresentationCache.Instance.Ready)
        {
            return;
        }

        var    simWorld  = GamePresentationCache.Instance.SimWorld;
        Entity localPawn = GamePresentationCache.Instance.LocalPawn;

        // find current pawn's doodle asset
        Guid currentDoodleGuid = Guid.Empty;

        if (simWorld.TryGetComponent(localPawn, out DoodleId doodleId))
        {
            currentDoodleGuid = doodleId.Guid;
        }

        PlayerDoodleAsset playerDoodleAsset = PlayerAssetManager.Instance.GetAsset <PlayerDoodleAsset>(currentDoodleGuid);

        // If pawn's doodle doesn't exist, create a new one + submit a sim input to assign it
        if (playerDoodleAsset == null)
        {
            playerDoodleAsset = PlayerAssetManager.Instance.CreateAsset <PlayerDoodleAsset>();

            PresentationHelpers.SubmitInput(new SimPlayerInputSetPawnDoodle(playerDoodleAsset.Guid, true));
        }

        // Load image into doodle texture
        playerDoodleAsset.Load(File.ReadAllBytes(imagePath));

        // publish changes
        PlayerAssetManager.Instance.PublishAssetChanges(playerDoodleAsset.Guid);
    }
Beispiel #2
0
    private void OnLevelSet(Level level)
    {
        if (IsLevelStarted)
        {
            Log.Error("Cannot start another level (not yet implemented)");
            return;
        }
        IsLevelStarted = true;
        PresentationHelpers.PresentationWorld.GetExistingSystem <TickSimulationSystem>().UnpauseSimulation(LEVEL_NOT_STARTED);

        if (Game.PlayingAsMaster)
        {
            // load simulation scenes
            PresentationHelpers.SubmitInput(new SimCommandLoadScene()
            {
                SceneName = SimManagersScene.SceneName
            });
            foreach (SceneInfo scene in level.SimulationScenes)
            {
                PresentationHelpers.SubmitInput(new SimCommandLoadScene()
                {
                    SceneName = scene.SceneName
                });
            }
        }

        // instantiate presentation
        Game.InstantiateGameplayPresentationSystems();

        // load presentation scenes
        foreach (SceneInfo scene in level.PresentationScenes)
        {
            SceneService.LoadAsync(scene.SceneName);
        }
    }
    public static void CheatInvicible()
    {
        var localPlayerInfo = PlayerHelpers.GetLocalPlayerInfo();

        if (localPlayerInfo == null)
        {
            Log.Warning("No local player found");
            return;
        }

        PresentationHelpers.SubmitInput(new SimInputCheatToggleInvincible()
        {
        });
    }
    public static void CheatGiveAllItems()
    {
        var localPlayerInfo = PlayerHelpers.GetLocalPlayerInfo();

        if (localPlayerInfo == null)
        {
            Log.Warning("No local player found");
            return;
        }

        PresentationHelpers.SubmitInput(new SimInputCheatAddAllItems()
        {
            PlayerId = localPlayerInfo.SimPlayerId,
        });
    }
    public static void CheatHealSelf(int amount)
    {
        var localPlayerInfo = PlayerHelpers.GetLocalPlayerInfo();

        if (localPlayerInfo == null)
        {
            Log.Warning("No local player found");
            return;
        }

        PresentationHelpers.SubmitInput(new SimInputCheatDamageSelf()
        {
            PlayerId = localPlayerInfo.SimPlayerId,
            Damage   = -amount
        });
    }
    public static void CheatSoloPlay(int playerIndex)
    {
        var localPlayerInfo = PlayerHelpers.GetLocalPlayerInfo();

        if (localPlayerInfo == null)
        {
            Log.Warning("No local player found");
            return;
        }

        PresentationHelpers.SubmitInput(new SimInputCheatSoloPlay()
        {
            PlayerId  = localPlayerInfo.SimPlayerId,
            PawnIndex = playerIndex
        });
    }
    public static void CheatImpulseSelf(float x, float y)
    {
        var localPlayerInfo = PlayerHelpers.GetLocalPlayerInfo();

        if (localPlayerInfo == null)
        {
            Log.Warning("No local player found");
            return;
        }

        PresentationHelpers.SubmitInput(new SimInputCheatImpulseSelf()
        {
            PlayerId     = localPlayerInfo.SimPlayerId,
            ImpulseValue = new fix2((fix)x, (fix)y)
        });
    }
    public static void CheatTeleportAtMouse()
    {
        var localPlayerInfo = PlayerHelpers.GetLocalPlayerInfo();

        if (localPlayerInfo == null)
        {
            Log.Warning("No local player found");
            return;
        }

        Vector3 destination = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        PresentationHelpers.SubmitInput(new SimInputCheatTeleport()
        {
            PlayerId    = localPlayerInfo.SimPlayerId,
            Destination = new fix2((fix)destination.x, (fix)destination.y)
        });
    }
 public static void CheatRemoveAllCooldowns()
 {
     PresentationHelpers.SubmitInput(new SimInputCheatRemoveAllCooldowns());
 }