-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix challenge prompt for Mantis Lords
- Loading branch information
1 parent
8e9cc13
commit 56f70cf
Showing
5 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
HKMP/Game/Client/Entity/Component/ChallengePromptComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Hkmp.Networking.Client; | ||
using Hkmp.Networking.Packet.Data; | ||
using Hkmp.Util; | ||
using UnityEngine; | ||
|
||
namespace Hkmp.Game.Client.Entity.Component; | ||
|
||
/// <inheritdoc /> | ||
/// This component manages the challenge prompt that appears for Mantis Lords. | ||
internal class ChallengePromptComponent : EntityComponent { | ||
/// <summary> | ||
/// The game object that handles the challenge prompt pop-up. | ||
/// </summary> | ||
private readonly GameObject _promptObj; | ||
|
||
public ChallengePromptComponent( | ||
NetClient netClient, | ||
ushort entityId, | ||
HostClientPair<GameObject> gameObject | ||
) : base(netClient, entityId, gameObject) { | ||
var hostObj = gameObject.Host; | ||
var parent = hostObj.transform.parent; | ||
_promptObj = parent.Find("Challenge Prompt").gameObject; | ||
|
||
var promptFsm = _promptObj.LocateMyFSM("Challenge Start"); | ||
promptFsm.InsertMethod("Take Control", 6, () => { | ||
var data = new EntityNetworkData { | ||
Type = EntityComponentType.ChallengePrompt | ||
}; | ||
data.Packet.Write(true); | ||
|
||
SendData(data); | ||
}); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override void InitializeHost() { | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override void Update(EntityNetworkData data) { | ||
var destroyPrompt = data.Packet.ReadBool(); | ||
if (!destroyPrompt) { | ||
return; | ||
} | ||
|
||
if (_promptObj != null) { | ||
Object.Destroy(_promptObj); | ||
} | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override void Destroy() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -395,6 +395,9 @@ | |
"type": "MantisLord", | ||
"fsm_name": "Mantis Lord" | ||
} | ||
], | ||
"components": [ | ||
"ChallengePrompt" | ||
] | ||
}, | ||
{ | ||
|