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

New stuff #1

Merged
merged 31 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7dc984c
minor fix
oleghcp Apr 1, 2023
88bd691
minor upd
oleghcp Apr 1, 2023
6e332ef
remove redundant constructors of ObjectPool
oleghcp Apr 1, 2023
4599495
minor upd
oleghcp Apr 1, 2023
5a29691
CertainTypesAttribute
oleghcp Apr 1, 2023
2acfa32
upd CertainTypesDrawer
oleghcp Apr 1, 2023
632d8f0
Update AiBehavior with Play/Stop methods
oleghcp Apr 1, 2023
db1c8b5
refactoring of AiBehavior
oleghcp Apr 1, 2023
c976432
refactoring of ai StateCondition
oleghcp Apr 2, 2023
3200ebc
refactoring
oleghcp Apr 2, 2023
608db2c
remove support of graph conversion to state machine
oleghcp Apr 2, 2023
3393699
refactoring
oleghcp Apr 2, 2023
df4e05f
upd NodeBased Condition drawer
oleghcp Apr 2, 2023
5e6e8c4
upd ConditionDrawer
oleghcp Apr 2, 2023
5cb08a3
upd ReferenceSelectionDrawer
oleghcp Apr 2, 2023
d3cff0f
refactoring of AiSimulation
oleghcp Apr 2, 2023
92a5f41
refactoring
oleghcp Apr 2, 2023
20b8f1e
remove common condition
oleghcp Apr 2, 2023
11f092e
refactoring; ai state graph
oleghcp Apr 2, 2023
0202032
upd AiStateGraph
oleghcp Apr 3, 2023
39600ba
upd nodebased StateCondition
oleghcp Apr 3, 2023
11fb77f
upd graph node root type checking
oleghcp Apr 6, 2023
8bdc713
BehaviorStateDrawer
oleghcp Apr 6, 2023
4e62408
ups StateConditionDrawer
oleghcp Apr 6, 2023
f10a6b7
CompleteHandlerDrawer
oleghcp Apr 6, 2023
69da78d
AiBehavior LateUpdate
oleghcp Apr 6, 2023
b130bed
Interruptible option
oleghcp Apr 6, 2023
d9d8f4c
remove unused extensions
oleghcp Apr 6, 2023
08bd047
upd UnityObjectExtensions
oleghcp Apr 6, 2023
70d4acb
version upd
oleghcp Apr 6, 2023
08412fc
AiBehavior play on Start
oleghcp Apr 6, 2023
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
Prev Previous commit
Next Next commit
Interruptible option
  • Loading branch information
oleghcp committed Apr 6, 2023
commit b130bede244fa907eef6218e64d0161b28af68b6
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ void IStateSet.Refresh(float deltaTime)
if (_currentState == null)
return;

if (!UpdateState(EnumerateFromAny()))
UpdateState(_currentState);
if (_currentState.Interruptible || _status == StateStatus.Complete)
{
if (!UpdateState(_currentState))
UpdateState(EnumerateFromAny());
}

if (_currentState != null && _status == StateStatus.Running)
if (_status == StateStatus.Running)
{
_status = _currentState.Refresh(deltaTime);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace UnityUtility.AiSimulation.NodeBased
[Serializable]
public abstract class BehaviorState : Node<BehaviorState>
{
[SerializeField]
private bool _interruptible = true;
[SerializeReference]
private CompleteHandler[] _onComlete;

Expand All @@ -21,6 +23,7 @@ public abstract class BehaviorState : Node<BehaviorState>

protected PermanentState PermanentState => _permanentState;
internal CompleteHandler[] CompleteHandlers => _onComlete;
public bool Interruptible => _interruptible;

internal void SetUp(PermanentState permanentState, GameObject gameObject)
{
Expand Down
28 changes: 17 additions & 11 deletions Code/Runtime/UnityUtility/AiSimulation/Simple/AiStateSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,32 @@ void IStateSet.Refresh(float deltaTime)
{
_permanentState?.Refresh(deltaTime);

for (int i = 0; i < _states.Length; i++)
if (_currentState == null)
return;

if (_currentState.Interruptible || _status == StateStatus.Complete)
{
if (_states[i].Available())
for (int i = 0; i < _states.Length; i++)
{
if (_states[i] != _currentState)
if (_states[i].Available())
{
if (_states[i] != _currentState)
{
#if UNITY_EDITOR
_prevState = _currentState;
_prevState = _currentState;
#endif
_currentState.OnEnd();
_currentState = _states[i];
_status = StateStatus.Running;
_currentState.OnBegin();
}
_currentState.OnEnd();
_currentState = _states[i];
_status = StateStatus.Running;
_currentState.OnBegin();
}

break;
break;
}
}
}

if (_currentState != null && _status == StateStatus.Running)
if (_status == StateStatus.Running)
{
_status = _currentState.Refresh(deltaTime);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace UnityUtility.AiSimulation.Simple
[Serializable]
public abstract class BehaviorState
{
[SerializeField]
private bool _interruptible = true;
[SerializeReference]
private StateCondition[] _conditions;
[SerializeReference]
Expand All @@ -22,6 +24,7 @@ public abstract class BehaviorState

protected PermanentState PermanentState => _permanentState;
internal CompleteHandler[] CompleteHandlers => _onComlete;
public bool Interruptible => _interruptible;

internal void SetUp(PermanentState permanentState, GameObject gameObject)
{
Expand Down