Skip to content

Commit

Permalink
This brings application to 14Mb.
Browse files Browse the repository at this point in the history
  • Loading branch information
kant2002 committed Jun 21, 2022
1 parent 71317a8 commit 1ba8296
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 16 additions & 1 deletion browser/src/CrossPlatform/AI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions desktop/FSharpWolfenstein.Desktop.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<TargetFramework>net6.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PublishAot Condition="'$(TargetFramework)' == 'net7.0'">true</PublishAot>
<IlcTrimMetadata>true</IlcTrimMetadata>
<TrimmerDefaultAction>link</TrimmerDefaultAction>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 1ba8296

Please sign in to comment.