10 changed files with 150 additions and 33 deletions
@ -0,0 +1,9 @@ |
|||||
|
using Entitas; |
||||
|
|
||||
|
namespace CoreGame.Logic |
||||
|
{ |
||||
|
[Logic] |
||||
|
public class BallRecycleComponent : IComponent |
||||
|
{ |
||||
|
} |
||||
|
} |
@ -0,0 +1,3 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 32996adfddf44fb7ac495e72b5ab4c52 |
||||
|
timeCreated: 1753759848 |
@ -0,0 +1,56 @@ |
|||||
|
//------------------------------------------------------------------------------
|
||||
|
// <auto-generated>
|
||||
|
// This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator.
|
||||
|
//
|
||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
|
// the code is regenerated.
|
||||
|
// </auto-generated>
|
||||
|
//------------------------------------------------------------------------------
|
||||
|
public partial class LogicEntity { |
||||
|
|
||||
|
static readonly CoreGame.Logic.BallRecycleComponent ballRecycleComponent = new CoreGame.Logic.BallRecycleComponent(); |
||||
|
|
||||
|
public bool isBallRecycle { |
||||
|
get { return HasComponent(LogicComponentsLookup.BallRecycle); } |
||||
|
set { |
||||
|
if (value != isBallRecycle) { |
||||
|
var index = LogicComponentsLookup.BallRecycle; |
||||
|
if (value) { |
||||
|
var componentPool = GetComponentPool(index); |
||||
|
var component = componentPool.Count > 0 |
||||
|
? componentPool.Pop() |
||||
|
: ballRecycleComponent; |
||||
|
|
||||
|
AddComponent(index, component); |
||||
|
} else { |
||||
|
RemoveComponent(index); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//------------------------------------------------------------------------------
|
||||
|
// <auto-generated>
|
||||
|
// This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator.
|
||||
|
//
|
||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
|
// the code is regenerated.
|
||||
|
// </auto-generated>
|
||||
|
//------------------------------------------------------------------------------
|
||||
|
public sealed partial class LogicMatcher { |
||||
|
|
||||
|
static Entitas.IMatcher<LogicEntity> _matcherBallRecycle; |
||||
|
|
||||
|
public static Entitas.IMatcher<LogicEntity> BallRecycle { |
||||
|
get { |
||||
|
if (_matcherBallRecycle == null) { |
||||
|
var matcher = (Entitas.Matcher<LogicEntity>)Entitas.Matcher<LogicEntity>.AllOf(LogicComponentsLookup.BallRecycle); |
||||
|
matcher.componentNames = LogicComponentsLookup.componentNames; |
||||
|
_matcherBallRecycle = matcher; |
||||
|
} |
||||
|
|
||||
|
return _matcherBallRecycle; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 873be48d947f2f14b91f618722d08b60 |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
@ -0,0 +1,36 @@ |
|||||
|
using Entitas; |
||||
|
using Sog; |
||||
|
|
||||
|
namespace CoreGame.Logic |
||||
|
{ |
||||
|
public class BallRecycleSystem : ITickSystem |
||||
|
{ |
||||
|
private readonly IGroup<LogicEntity> m_BallRecycleGroup; |
||||
|
|
||||
|
public BallRecycleSystem(LogicContext logicContext) |
||||
|
{ |
||||
|
m_BallRecycleGroup = logicContext.GetGroup(MatcherSvc.s_BallRecycle); |
||||
|
} |
||||
|
|
||||
|
public void Tick() |
||||
|
{ |
||||
|
var tmpBuffer = m_BallRecycleGroup.GetEntitiesWithTmpBuffer(); |
||||
|
for (int i = 0; i < tmpBuffer.Count; i++) |
||||
|
{ |
||||
|
var entity = tmpBuffer.Buffer[i]; |
||||
|
var ballComp = entity.ballData; |
||||
|
var fCollisionBody = entity.fCollision.body; |
||||
|
var casterEid = ballComp.casterEid; |
||||
|
var logicContext = entity.logicContext; |
||||
|
var heroEntity = logicContext.GetEntity(casterEid); |
||||
|
if (heroEntity) |
||||
|
{ |
||||
|
var transform = heroEntity.logicTransform; |
||||
|
var dir = transform.position - fCollisionBody.Position; |
||||
|
fCollisionBody.LinearVelocityNormalized = FixedMath.Normalize(dir); |
||||
|
fCollisionBody.LinearVelocity = fCollisionBody.LinearVelocityNormalized * fCollisionBody.Velocity; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,3 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 74206916e76b4c09ae9d066000d5ad1a |
||||
|
timeCreated: 1753759310 |
Loading…
Reference in new issue