forked from wickedwaifus/wicked-waifus-rs
push better version of prototype that actually runs
This commit is contained in:
parent
ce265b89ca
commit
af681c8f15
3 changed files with 329 additions and 213 deletions
|
@ -1,12 +1,21 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use wicked_waifus_data::pb_components::action::{CollectParams, UnlockTeleportTrigger};
|
use wicked_waifus_protocol::{
|
||||||
use wicked_waifus_protocol::{ItemRewardNotify, NormalItemUpdateNotify, RewardItemInfo, WR};
|
CommonTagData, EntityCommonTagNotify, EntityStateReadyNotify, ItemRewardNotify,
|
||||||
|
NormalItemUpdateNotify, RewardItemInfo, WR,
|
||||||
use crate::logic::{
|
|
||||||
player::{ItemUsage, Player},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use wicked_waifus_data::pb_components::action::{
|
||||||
|
ChangeSelfEntityState, CollectParams, UnlockTeleportTrigger
|
||||||
|
};
|
||||||
|
use wicked_waifus_data::pb_components::entity_state::EntityStateComponent;
|
||||||
|
|
||||||
|
use crate::logic::ecs::component::ComponentContainer;
|
||||||
|
use crate::logic::handler::handle_action;
|
||||||
|
use crate::logic::player::{ItemUsage, Player};
|
||||||
|
use crate::logic::utils::tag_utils;
|
||||||
|
use crate::query_components;
|
||||||
|
|
||||||
pub fn collect_action(
|
pub fn collect_action(
|
||||||
player: &mut Player,
|
player: &mut Player,
|
||||||
_entity_id: i64,
|
_entity_id: i64,
|
||||||
|
@ -69,7 +78,7 @@ pub fn collect_action(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn unlock_teleport_trigger_action(
|
pub fn unlock_teleport_trigger_action(
|
||||||
player: &mut Player,
|
player: &mut Player,
|
||||||
_entity_id: i64,
|
_entity_id: i64,
|
||||||
_level_entity_data: &wicked_waifus_data::LevelEntityConfigData,
|
_level_entity_data: &wicked_waifus_data::LevelEntityConfigData,
|
||||||
|
@ -78,3 +87,79 @@ fn unlock_teleport_trigger_action(
|
||||||
) {
|
) {
|
||||||
player.unlock_teleport(action.teleport_id)
|
player.unlock_teleport(action.teleport_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn change_self_entity_state_action(
|
||||||
|
player: &mut Player,
|
||||||
|
entity_id: i64,
|
||||||
|
level_entity_data: &wicked_waifus_data::LevelEntityConfigData,
|
||||||
|
template_config: &wicked_waifus_data::TemplateConfigData,
|
||||||
|
action: ChangeSelfEntityState,
|
||||||
|
) {
|
||||||
|
let state = tag_utils::get_tag_id_by_name(action.entity_state.as_str());
|
||||||
|
|
||||||
|
// TODO: update Tag::CommonEntityTags too??
|
||||||
|
let old_state = {
|
||||||
|
let world_ref = player.world.borrow();
|
||||||
|
let world = world_ref.get_world_entity();
|
||||||
|
let mut state_tag = query_components!(world, entity_id, StateTag).0.unwrap();
|
||||||
|
let old_state = state_tag.state_tag_id;
|
||||||
|
tracing::debug!("ChangeSelfEntityState: old state {old_state} -> new state: {state}");
|
||||||
|
state_tag.state_tag_id = state;
|
||||||
|
old_state
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(entity_state_component) = level_entity_data
|
||||||
|
.components_data
|
||||||
|
.entity_state_component
|
||||||
|
.as_ref()
|
||||||
|
.or(template_config
|
||||||
|
.components_data
|
||||||
|
.entity_state_component
|
||||||
|
.as_ref())
|
||||||
|
.cloned()
|
||||||
|
{
|
||||||
|
let entity_state_component: EntityStateComponent = entity_state_component; // TODO: Remove this line, used for casting only
|
||||||
|
|
||||||
|
// TODO: implement rest of cases
|
||||||
|
if let Some(state_change_behaviors) = entity_state_component.state_change_behaviors {
|
||||||
|
for state_change_behavior in state_change_behaviors {
|
||||||
|
// TODO: implement rest of cases
|
||||||
|
let expected = tag_utils::get_tag_id_by_name(state_change_behavior.state.as_str());
|
||||||
|
|
||||||
|
if expected == state {
|
||||||
|
if let Some(actions) = state_change_behavior.action {
|
||||||
|
for sub in actions {
|
||||||
|
handle_action(
|
||||||
|
player,
|
||||||
|
entity_id,
|
||||||
|
level_entity_data,
|
||||||
|
template_config,
|
||||||
|
sub,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.notify(EntityCommonTagNotify {
|
||||||
|
id: entity_id,
|
||||||
|
tags: vec![
|
||||||
|
CommonTagData {
|
||||||
|
tag_id: old_state,
|
||||||
|
remove_tag_ids: false,
|
||||||
|
}, // Remove
|
||||||
|
CommonTagData {
|
||||||
|
tag_id: state,
|
||||||
|
remove_tag_ids: true,
|
||||||
|
}, // Add
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
player.notify(EntityStateReadyNotify {
|
||||||
|
entity_id,
|
||||||
|
tag_id: state,
|
||||||
|
ready: true, // TODO: Always true? or shall we compare it to something??
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ macro_rules! handle_push {
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! handle_action {
|
macro_rules! handle_action {
|
||||||
($($variant:ident),*) => {
|
($($variant:ident),* $(,)?) => {
|
||||||
use wicked_waifus_data::pb_components::action::Action;
|
use wicked_waifus_data::pb_components::action::Action;
|
||||||
use crate::logic::player::Player;
|
use crate::logic::player::Player;
|
||||||
|
|
||||||
|
@ -124,18 +124,24 @@ macro_rules! handle_action {
|
||||||
entity_id: i64,
|
entity_id: i64,
|
||||||
level_entity_data: &wicked_waifus_data::LevelEntityConfigData,
|
level_entity_data: &wicked_waifus_data::LevelEntityConfigData,
|
||||||
template_config: &wicked_waifus_data::TemplateConfigData,
|
template_config: &wicked_waifus_data::TemplateConfigData,
|
||||||
element: Action
|
action: Action
|
||||||
) {
|
) {
|
||||||
::paste::paste! {
|
::paste::paste! {
|
||||||
match element {
|
match action {
|
||||||
$(
|
$(
|
||||||
Action::$variant(inner) => {
|
Action::$variant(inner) => {
|
||||||
paste::paste! {
|
[<$variant:snake _action>](
|
||||||
[<$variant:snake _action>](player, entity_id, level_entity_data, template_config, inner.params)
|
player,
|
||||||
}
|
entity_id,
|
||||||
|
level_entity_data,
|
||||||
|
template_config,
|
||||||
|
inner.params
|
||||||
|
)
|
||||||
},
|
},
|
||||||
_ => tracing::debug!("hi"),
|
|
||||||
)*
|
)*
|
||||||
|
_ => {
|
||||||
|
::tracing::warn!("Action not implemented for: {:?}", action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -320,190 +326,190 @@ handle_push! {
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_action! {
|
handle_action! {
|
||||||
ExecBattleAction,
|
// ExecBattleAction,
|
||||||
WaitBattleCondition,
|
// WaitBattleCondition,
|
||||||
SetBattleState,
|
// SetBattleState,
|
||||||
PlayFlow,
|
// PlayFlow,
|
||||||
Collect,
|
Collect,
|
||||||
LeisureInteract,
|
// LeisureInteract,
|
||||||
UnlockTeleportTrigger,
|
UnlockTeleportTrigger,
|
||||||
EnableTemporaryTeleport,
|
// EnableTemporaryTeleport,
|
||||||
OpenSystemBoard,
|
// OpenSystemBoard,
|
||||||
OpenSystemFunction,
|
// OpenSystemFunction,
|
||||||
ChangeSelfEntityState,
|
ChangeSelfEntityState,
|
||||||
SetPlayerOperationRestriction,
|
// SetPlayerOperationRestriction,
|
||||||
Wait,
|
// Wait,
|
||||||
ChangeEntityState,
|
// ChangeEntityState,
|
||||||
Log,
|
// Log,
|
||||||
EnableNearbyTracking,
|
// EnableNearbyTracking,
|
||||||
TeleportDungeon,
|
// TeleportDungeon,
|
||||||
DestroySelf,
|
// DestroySelf,
|
||||||
CameraLookAt,
|
// CameraLookAt,
|
||||||
StopCameraLookAt,
|
// StopCameraLookAt,
|
||||||
EnterOrbitalCamera,
|
// EnterOrbitalCamera,
|
||||||
ExitOrbitalCamera,
|
// ExitOrbitalCamera,
|
||||||
SendAiEvent,
|
// SendAiEvent,
|
||||||
SetInteractionLockState,
|
// SetInteractionLockState,
|
||||||
AwakeEntity,
|
// AwakeEntity,
|
||||||
ChangeLiftTarget,
|
// ChangeLiftTarget,
|
||||||
CalculateVar,
|
// CalculateVar,
|
||||||
AddBuffToPlayer,
|
// AddBuffToPlayer,
|
||||||
RemoveBuffFromPlayer,
|
// RemoveBuffFromPlayer,
|
||||||
AddBuffToEntity,
|
// AddBuffToEntity,
|
||||||
RemoveBuffFromEntity,
|
// RemoveBuffFromEntity,
|
||||||
Prompt,
|
// Prompt,
|
||||||
SetEntityVisible,
|
// SetEntityVisible,
|
||||||
DestroyEntity,
|
// DestroyEntity,
|
||||||
GuideTrigger,
|
// GuideTrigger,
|
||||||
TriggerCameraShake,
|
// TriggerCameraShake,
|
||||||
SetVar,
|
// SetVar,
|
||||||
VehicleEnter,
|
// VehicleEnter,
|
||||||
VehicleExitPlayer,
|
// VehicleExitPlayer,
|
||||||
LockEntity,
|
// LockEntity,
|
||||||
UnlockEntity,
|
// UnlockEntity,
|
||||||
CommonTip,
|
// CommonTip,
|
||||||
CommonTip2,
|
// CommonTip2,
|
||||||
PostAkEvent,
|
// PostAkEvent,
|
||||||
VehicleEnterNpc,
|
// VehicleEnterNpc,
|
||||||
VehicleExitNpc,
|
// VehicleExitNpc,
|
||||||
PlayerLookAt,
|
// PlayerLookAt,
|
||||||
PlayBubble,
|
// PlayBubble,
|
||||||
AddPlayBubble,
|
// AddPlayBubble,
|
||||||
ClearPlayBubble,
|
// ClearPlayBubble,
|
||||||
ExecRiskHarvestEffect,
|
// ExecRiskHarvestEffect,
|
||||||
EnableLevelPlay,
|
// EnableLevelPlay,
|
||||||
ClaimLevelPlayReward,
|
// ClaimLevelPlayReward,
|
||||||
SettlementDungeon,
|
// SettlementDungeon,
|
||||||
ExitDungeon,
|
// ExitDungeon,
|
||||||
FinishDungeon,
|
// FinishDungeon,
|
||||||
RecordDungeonEvent,
|
// RecordDungeonEvent,
|
||||||
RecoverDurability,
|
// RecoverDurability,
|
||||||
FadeInScreen,
|
// FadeInScreen,
|
||||||
FadeOutScreen,
|
// FadeOutScreen,
|
||||||
ChangeNpcPerformState,
|
// ChangeNpcPerformState,
|
||||||
EntityTurnTo,
|
// EntityTurnTo,
|
||||||
EntityLookAt,
|
// EntityLookAt,
|
||||||
ToggleMapMarkState,
|
// ToggleMapMarkState,
|
||||||
RandomVar,
|
// RandomVar,
|
||||||
ModifySceneItemAttributeTag,
|
// ModifySceneItemAttributeTag,
|
||||||
VehicleWaterfallClimbing,
|
// VehicleWaterfallClimbing,
|
||||||
VehicleTeleport,
|
// VehicleTeleport,
|
||||||
RogueGotoNextFloor,
|
// RogueGotoNextFloor,
|
||||||
RogueReceiveReward,
|
// RogueReceiveReward,
|
||||||
RogueSelectRoom,
|
// RogueSelectRoom,
|
||||||
RogueActivatePortal,
|
// RogueActivatePortal,
|
||||||
MowingTowerGotoNextFloor,
|
// MowingTowerGotoNextFloor,
|
||||||
SlashAndTowerGotoNextFloor,
|
// SlashAndTowerGotoNextFloor,
|
||||||
PlayMontage,
|
// PlayMontage,
|
||||||
OpenSystemBoardWithReturn,
|
// OpenSystemBoardWithReturn,
|
||||||
UnlockSystemItem,
|
// UnlockSystemItem,
|
||||||
SetSportsState,
|
// SetSportsState,
|
||||||
OpenSimpleGameplay,
|
// OpenSimpleGameplay,
|
||||||
PlayEffect,
|
// PlayEffect,
|
||||||
PlayEffect2,
|
// PlayEffect2,
|
||||||
RestorePlayerCameraAdjustment,
|
// RestorePlayerCameraAdjustment,
|
||||||
AdjustPlayerCamera,
|
// AdjustPlayerCamera,
|
||||||
SetPlayerPos,
|
// SetPlayerPos,
|
||||||
MoveWithSpline,
|
// MoveWithSpline,
|
||||||
EnableSplineMoveModel,
|
// EnableSplineMoveModel,
|
||||||
ToggleScanSplineEffect,
|
// ToggleScanSplineEffect,
|
||||||
MoveSceneItem,
|
// MoveSceneItem,
|
||||||
StopSceneItemMove,
|
// StopSceneItemMove,
|
||||||
FireBullet,
|
// FireBullet,
|
||||||
ClearFishingCabinInSaleItems,
|
// ClearFishingCabinInSaleItems,
|
||||||
AcceptFishingEntrust,
|
// AcceptFishingEntrust,
|
||||||
DestroyFishingBoat,
|
// DestroyFishingBoat,
|
||||||
SetJigsawItem,
|
// SetJigsawItem,
|
||||||
SetJigsawFoundation,
|
// SetJigsawFoundation,
|
||||||
SetTeleControl,
|
// SetTeleControl,
|
||||||
SetEntityClientVisible,
|
// SetEntityClientVisible,
|
||||||
ToggleHighlightExploreUi,
|
// ToggleHighlightExploreUi,
|
||||||
ExecAlertSystemAction,
|
// ExecAlertSystemAction,
|
||||||
AddFlowInteractOption,
|
// AddFlowInteractOption,
|
||||||
RemoveFlowInteractOption,
|
// RemoveFlowInteractOption,
|
||||||
EnableHostility,
|
// EnableHostility,
|
||||||
ChangePhantomFormation,
|
// ChangePhantomFormation,
|
||||||
RestorePhantomFormation,
|
// RestorePhantomFormation,
|
||||||
ChangeTimer,
|
// ChangeTimer,
|
||||||
ToggleTimerPauseState,
|
// ToggleTimerPauseState,
|
||||||
ChangeFightTeam,
|
// ChangeFightTeam,
|
||||||
AddTrialFollowShooter,
|
// AddTrialFollowShooter,
|
||||||
RemoveTrialFollowShooter,
|
// RemoveTrialFollowShooter,
|
||||||
AddTrialCharacter,
|
// AddTrialCharacter,
|
||||||
RemoveTrialCharacter,
|
// RemoveTrialCharacter,
|
||||||
SetAreaState,
|
// SetAreaState,
|
||||||
SwitchSubLevels,
|
// SwitchSubLevels,
|
||||||
ChangeTeamPosition,
|
// ChangeTeamPosition,
|
||||||
GetItem,
|
// GetItem,
|
||||||
CreatePrefab,
|
// CreatePrefab,
|
||||||
DestroyPrefab,
|
// DestroyPrefab,
|
||||||
CompleteGuide,
|
// CompleteGuide,
|
||||||
PlayDynamicSettlement,
|
// PlayDynamicSettlement,
|
||||||
UsePhantomSkill,
|
// UsePhantomSkill,
|
||||||
HideTargetRange,
|
// HideTargetRange,
|
||||||
ChangeOtherState,
|
// ChangeOtherState,
|
||||||
SetRegionConfig,
|
// SetRegionConfig,
|
||||||
SetReviveRegion,
|
// SetReviveRegion,
|
||||||
ExecResurrection,
|
// ExecResurrection,
|
||||||
ShowTargetRange,
|
// ShowTargetRange,
|
||||||
SetTime,
|
// SetTime,
|
||||||
SetTimeLockState,
|
// SetTimeLockState,
|
||||||
EnableSystem,
|
// EnableSystem,
|
||||||
EnableAoiNotify,
|
// EnableAoiNotify,
|
||||||
SetForceLock,
|
// SetForceLock,
|
||||||
PlayRegisteredMontage,
|
// PlayRegisteredMontage,
|
||||||
SetAudioState,
|
// SetAudioState,
|
||||||
HideGroup,
|
// HideGroup,
|
||||||
ShowHidedGroup,
|
// ShowHidedGroup,
|
||||||
HideSpecificEntities,
|
// HideSpecificEntities,
|
||||||
ShowSpecificEntities,
|
// ShowSpecificEntities,
|
||||||
RemovePreloadResource,
|
// RemovePreloadResource,
|
||||||
Preload,
|
// Preload,
|
||||||
EnableAI,
|
// EnableAI,
|
||||||
SwitchDataLayers,
|
// SwitchDataLayers,
|
||||||
DestroyQuest,
|
// DestroyQuest,
|
||||||
DestroyQuestItem,
|
// DestroyQuestItem,
|
||||||
PromptQuestChapterUI,
|
// PromptQuestChapterUI,
|
||||||
TakePlotPhoto,
|
// TakePlotPhoto,
|
||||||
SetWuYinQuState,
|
// SetWuYinQuState,
|
||||||
RunActions,
|
// RunActions,
|
||||||
ManualOccupations,
|
// ManualOccupations,
|
||||||
SetWeather,
|
// SetWeather,
|
||||||
SendNpcMail,
|
// SendNpcMail,
|
||||||
EnableFunction,
|
// EnableFunction,
|
||||||
FocusOnMapMark,
|
// FocusOnMapMark,
|
||||||
CharacterLookAt,
|
// CharacterLookAt,
|
||||||
AddGuestCharacter,
|
// AddGuestCharacter,
|
||||||
RemoveGuestCharacter,
|
// RemoveGuestCharacter,
|
||||||
TeleportToAndEnterVehicle,
|
// TeleportToAndEnterVehicle,
|
||||||
SetAreaTimeState,
|
// SetAreaTimeState,
|
||||||
ResetPlayerCameraFocus,
|
// ResetPlayerCameraFocus,
|
||||||
ResetLevelPlay,
|
// ResetLevelPlay,
|
||||||
VehicleSprint,
|
// VehicleSprint,
|
||||||
VehicleMoveWithPathLine,
|
// VehicleMoveWithPathLine,
|
||||||
ClientPreEnableSubLevels,
|
// ClientPreEnableSubLevels,
|
||||||
GuestOperateUiAnimation,
|
// GuestOperateUiAnimation,
|
||||||
ChangeEntityCamp,
|
// ChangeEntityCamp,
|
||||||
NewMoveWithSpline,
|
// NewMoveWithSpline,
|
||||||
DangoAbyssActivatePortal,
|
// DangoAbyssActivatePortal,
|
||||||
DangoAbyssCreateRewardTreasureBox,
|
// DangoAbyssCreateRewardTreasureBox,
|
||||||
DangoAbyssGotoNextFloor,
|
// DangoAbyssGotoNextFloor,
|
||||||
DangoAbyssReceiveReward,
|
// DangoAbyssReceiveReward,
|
||||||
SummonEntity,
|
// SummonEntity,
|
||||||
GetRewardByInteract,
|
// GetRewardByInteract,
|
||||||
OpenQte,
|
// OpenQte,
|
||||||
ActiveAntiGravitySafePoint,
|
// ActiveAntiGravitySafePoint,
|
||||||
BvbPlayDialog,
|
// BvbPlayDialog,
|
||||||
BvbSendSystemEvent,
|
// BvbSendSystemEvent,
|
||||||
BvbSendAiEvent,
|
// BvbSendAiEvent,
|
||||||
BvbPlayerOperationConstraint,
|
// BvbPlayerOperationConstraint,
|
||||||
ExecClientBattleAction,
|
// ExecClientBattleAction,
|
||||||
TriggerSpecificScanEffect,
|
// TriggerSpecificScanEffect,
|
||||||
SetActorVar,
|
// SetActorVar,
|
||||||
RunActorCustomEvent,
|
// RunActorCustomEvent,
|
||||||
StopUiScreenEffect,
|
// StopUiScreenEffect,
|
||||||
StopNewMoveWithSpline,
|
// StopNewMoveWithSpline,
|
||||||
RequestSystemFunction
|
// RequestSystemFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_logic_message(player: &mut super::player::Player, msg: Message) {
|
pub fn handle_logic_message(player: &mut super::player::Player, msg: Message) {
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use wicked_waifus_protocol::{CommonTagData, EntityCommonTagNotify, EntityStateReadyNotify, ItemRewardNotify, NormalItemUpdateNotify, RewardItemInfo, WR};
|
use wicked_waifus_protocol::{
|
||||||
|
CommonTagData, EntityCommonTagNotify, EntityStateReadyNotify, ItemRewardNotify,
|
||||||
|
NormalItemUpdateNotify, RewardItemInfo, WR,
|
||||||
|
};
|
||||||
|
|
||||||
use wicked_waifus_data::pb_components::action::{Action, ChangeSelfEntityState, UnlockTeleportTrigger};
|
use wicked_waifus_data::pb_components::action::{
|
||||||
|
Action, ChangeSelfEntityState, UnlockTeleportTrigger,
|
||||||
|
};
|
||||||
use wicked_waifus_data::pb_components::entity_state::EntityStateComponent;
|
use wicked_waifus_data::pb_components::entity_state::EntityStateComponent;
|
||||||
|
|
||||||
use crate::logic::ecs::component::ComponentContainer;
|
use crate::logic::ecs::component::ComponentContainer;
|
||||||
|
@ -12,11 +17,9 @@ use crate::logic::utils::tag_utils;
|
||||||
use crate::query_components;
|
use crate::query_components;
|
||||||
|
|
||||||
macro_rules! unimplemented_action {
|
macro_rules! unimplemented_action {
|
||||||
($action:ident) => {
|
($action:ident) => {{
|
||||||
{
|
tracing::warn!("Action not implemented for: {:?}", $action);
|
||||||
tracing::warn!("Action not implemented for: {:?}", $action);
|
}};
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn perform_action(player: &mut Player,
|
// pub fn perform_action(player: &mut Player,
|
||||||
|
@ -212,11 +215,13 @@ macro_rules! unimplemented_action {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
fn change_self_entity_state_action(player: &mut Player,
|
pub fn change_self_entity_state_action(
|
||||||
entity_id: i64,
|
player: &mut Player,
|
||||||
level_entity_data: &wicked_waifus_data::LevelEntityConfigData,
|
entity_id: i64,
|
||||||
template_config: &wicked_waifus_data::TemplateConfigData,
|
level_entity_data: &wicked_waifus_data::LevelEntityConfigData,
|
||||||
action: ChangeSelfEntityState) {
|
template_config: &wicked_waifus_data::TemplateConfigData,
|
||||||
|
action: ChangeSelfEntityState,
|
||||||
|
) {
|
||||||
let state = tag_utils::get_tag_id_by_name(action.entity_state.as_str());
|
let state = tag_utils::get_tag_id_by_name(action.entity_state.as_str());
|
||||||
|
|
||||||
// TODO: update Tag::CommonEntityTags too??
|
// TODO: update Tag::CommonEntityTags too??
|
||||||
|
@ -230,9 +235,17 @@ fn change_self_entity_state_action(player: &mut Player,
|
||||||
old_state
|
old_state
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(entity_state_component) = level_entity_data.components_data.entity_state_component.as_ref()
|
if let Some(entity_state_component) = level_entity_data
|
||||||
.or(template_config.components_data.entity_state_component.as_ref()).cloned() {
|
.components_data
|
||||||
let entity_state_component: EntityStateComponent = entity_state_component; // TODO: Remove this line, used for casting only
|
.entity_state_component
|
||||||
|
.as_ref()
|
||||||
|
.or(template_config
|
||||||
|
.components_data
|
||||||
|
.entity_state_component
|
||||||
|
.as_ref())
|
||||||
|
.cloned()
|
||||||
|
{
|
||||||
|
let entity_state_component: EntityStateComponent = entity_state_component; // TODO: Remove this line, used for casting only
|
||||||
|
|
||||||
// TODO: implement rest of cases
|
// TODO: implement rest of cases
|
||||||
if let Some(state_change_behaviors) = entity_state_component.state_change_behaviors {
|
if let Some(state_change_behaviors) = entity_state_component.state_change_behaviors {
|
||||||
|
@ -243,7 +256,13 @@ fn change_self_entity_state_action(player: &mut Player,
|
||||||
if expected == state {
|
if expected == state {
|
||||||
if let Some(actions) = state_change_behavior.action {
|
if let Some(actions) = state_change_behavior.action {
|
||||||
for sub in actions {
|
for sub in actions {
|
||||||
handle_action(player, entity_id, level_entity_data, template_config, sub);
|
handle_action(
|
||||||
|
player,
|
||||||
|
entity_id,
|
||||||
|
level_entity_data,
|
||||||
|
template_config,
|
||||||
|
sub,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,8 +273,14 @@ fn change_self_entity_state_action(player: &mut Player,
|
||||||
player.notify(EntityCommonTagNotify {
|
player.notify(EntityCommonTagNotify {
|
||||||
id: entity_id,
|
id: entity_id,
|
||||||
tags: vec![
|
tags: vec![
|
||||||
CommonTagData { tag_id: old_state, remove_tag_ids: false }, // Remove
|
CommonTagData {
|
||||||
CommonTagData { tag_id: state, remove_tag_ids: true }, // Add
|
tag_id: old_state,
|
||||||
|
remove_tag_ids: false,
|
||||||
|
}, // Remove
|
||||||
|
CommonTagData {
|
||||||
|
tag_id: state,
|
||||||
|
remove_tag_ids: true,
|
||||||
|
}, // Add
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -264,4 +289,4 @@ fn change_self_entity_state_action(player: &mut Player,
|
||||||
tag_id: state,
|
tag_id: state,
|
||||||
ready: true, // TODO: Always true? or shall we compare it to something??
|
ready: true, // TODO: Always true? or shall we compare it to something??
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue