Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sdk7 smart wearable restricted actions call from ui #6012

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,13 @@ public struct InternalEngineInfo : IInternalComponent
public uint SceneTick;
public float SceneInitialRunTime;
public int SceneInitialFrameCount;
public uint EnableRestrictedActionTick;

public InternalEngineInfo(uint sceneTick, float sceneInitialRunTime)
{
this.dirty = false;
this.SceneTick = sceneTick;
this.SceneInitialRunTime = sceneInitialRunTime;
this.SceneInitialFrameCount = Time.frameCount;
this.EnableRestrictedActionTick = 0;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,7 @@ internal bool IsSceneRestrictedActionEnabled(int sceneNumber)
{
InternalEngineInfo engineInfo = engineInfoComponent.GetFor(scene, SpecialEntityId.SCENE_ROOT_ENTITY)!.Value.model;
uint sceneTick = engineInfo.SceneTick;

const uint TICK_THRESHOLD = 2;

return sceneTick != 0
&& engineInfo.EnableRestrictedActionTick != 0
&& sceneTick <= (engineInfo.EnableRestrictedActionTick + TICK_THRESHOLD);
return sceneTick != 0;
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public void Update()
if (IsValidInputForRestrictedActions(entityId, actionButton, evtType, hit))
{
restrictedActionEnabled = true;
engineInfoModel.EnableRestrictedActionTick = engineInfoModel.SceneTick;
engineInfoComponent.PutFor(currentSceneNumber, SpecialEntityId.SCENE_ROOT_ENTITY, engineInfoModel);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,107 +155,5 @@ public void StoreSceneTickInResult()
(result) => result.TickNumber == 3
);
}

[Test]
public void EnableRestrictedActionsOnValidInput()
{
const uint CURRENT_TICK = 823;

inputResultComponent.AddEvent(scene, new InternalInputEventResults.EventData()
{
button = InputAction.IaPrimary,
type = PointerEventType.PetDown,
hit = new RaycastHit()
{
EntityId = 66
}
});

internalComponents.EngineInfo.PutFor(scene, SpecialEntityId.SCENE_ROOT_ENTITY, new InternalEngineInfo()
{
SceneTick = CURRENT_TICK,
EnableRestrictedActionTick = 0
});

updateSystems();

var engineInfo = internalComponents.EngineInfo.GetFor(scene, SpecialEntityId.SCENE_ROOT_ENTITY)!.Value.model;
Assert.AreEqual(CURRENT_TICK, engineInfo.EnableRestrictedActionTick);
}

[Test]
public void NotEnableRestrictedActionsOnInvalidInputType()
{
inputResultComponent.AddEvent(scene, new InternalInputEventResults.EventData()
{
button = InputAction.IaPrimary,
type = PointerEventType.PetHoverEnter,
hit = new RaycastHit()
{
EntityId = 66
}
});

internalComponents.EngineInfo.PutFor(scene, SpecialEntityId.SCENE_ROOT_ENTITY, new InternalEngineInfo()
{
SceneTick = 823,
EnableRestrictedActionTick = 0
});

updateSystems();

var engineInfo = internalComponents.EngineInfo.GetFor(scene, SpecialEntityId.SCENE_ROOT_ENTITY)!.Value.model;
Assert.AreEqual(0, engineInfo.EnableRestrictedActionTick);
}

[Test]
public void NotEnableRestrictedActionsOnInvalidInputHit()
{
inputResultComponent.AddEvent(scene, new InternalInputEventResults.EventData()
{
button = InputAction.IaPrimary,
type = PointerEventType.PetDown,
hit = null
});

internalComponents.EngineInfo.PutFor(scene, SpecialEntityId.SCENE_ROOT_ENTITY, new InternalEngineInfo()
{
SceneTick = 823,
EnableRestrictedActionTick = 0
});

updateSystems();

var engineInfo = internalComponents.EngineInfo.GetFor(scene, SpecialEntityId.SCENE_ROOT_ENTITY)!.Value.model;
Assert.AreEqual(0, engineInfo.EnableRestrictedActionTick);
}

[Test]
public void NotEnableRestrictedActionsOnValidInputFromOtherScene()
{
const uint CURRENT_TICK = 823;
var sceneWherePlayerIsNotCurrentlyOn = testUtils.CreateScene(667);

inputResultComponent.AddEvent(sceneWherePlayerIsNotCurrentlyOn, new InternalInputEventResults.EventData()
{
button = InputAction.IaPrimary,
type = PointerEventType.PetDown,
hit = new RaycastHit()
{
EntityId = 66
}
});

internalComponents.EngineInfo.PutFor(sceneWherePlayerIsNotCurrentlyOn, SpecialEntityId.SCENE_ROOT_ENTITY, new InternalEngineInfo()
{
SceneTick = CURRENT_TICK,
EnableRestrictedActionTick = 0
});

updateSystems();

var engineInfo = internalComponents.EngineInfo.GetFor(sceneWherePlayerIsNotCurrentlyOn, SpecialEntityId.SCENE_ROOT_ENTITY)!.Value.model;
Assert.AreEqual(0, engineInfo.EnableRestrictedActionTick);
}
}
}
Loading