From 1ba8296e2a5d455201cfe116b523bc59c5b55981 Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Tue, 21 Jun 2022 10:35:57 +0600 Subject: [PATCH] This brings application to 14Mb. --- browser/src/CrossPlatform/AI.fs | 17 ++++++++++++++++- desktop/FSharpWolfenstein.Desktop.fsproj | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/browser/src/CrossPlatform/AI.fs b/browser/src/CrossPlatform/AI.fs index f589450..ed19bea 100644 --- a/browser/src/CrossPlatform/AI.fs +++ b/browser/src/CrossPlatform/AI.fs @@ -58,12 +58,27 @@ let getNextState canSeePlayer enemy = ) () | _ -> enemy.State +// This conversion required because FSharp do not play +// along with NativeAOT inside interpolated strings + enums. +// Be explicit about how to display strings. +let getStateString state = + match state with + | EnemyStateType.Standing -> "Standing" + | EnemyStateType.Ambushing -> "Ambushing" + | EnemyStateType.Attack -> "Attack" + | EnemyStateType.Path -> "Path" + | EnemyStateType.Pain -> "Pain" + | EnemyStateType.Shoot -> "Shoot" + | EnemyStateType.Chase -> "Chase" + | EnemyStateType.Die -> "Die" + | EnemyStateType.Dead -> "Dead" + let preProcess game enemy = // preprocess looks for state changes based on the current game world state let canSeePlayer = enemy |> isPlayerVisibleToEnemy game let newState = enemy |> getNextState canSeePlayer if newState <> enemy.State then - Utils.log $"Enemy at {enemy.BasicGameObject.Position.vX}, {enemy.BasicGameObject.Position.vY} moving from {enemy.State} to {newState}" + Utils.log $"Enemy at {enemy.BasicGameObject.Position.vX}, {enemy.BasicGameObject.Position.vY} moving from {getStateString enemy.State} to {getStateString newState}" { enemy with State = newState } else enemy diff --git a/desktop/FSharpWolfenstein.Desktop.fsproj b/desktop/FSharpWolfenstein.Desktop.fsproj index 74c5450..39829cb 100644 --- a/desktop/FSharpWolfenstein.Desktop.fsproj +++ b/desktop/FSharpWolfenstein.Desktop.fsproj @@ -5,6 +5,8 @@ net6.0 true true + true + link