public static void RequestDamage(ISimGameWorldReadWriteAccessor accessor, Entity target, fix amount, uint effectGroupID = uint.MaxValue) { var request = new HealthChangeRequestData() { Amount = -amount, Target = target, EffectGroupID = effectGroupID }; accessor.GetExistingSystem <ApplyDamageSystem>().RequestHealthChange(request); }
public static void RequestTeleport(ISimGameWorldReadWriteAccessor accessor, Entity entity, fix2 destination) { var requests = accessor.GetExistingSystem <TeleportSystem>().GetRequestBuffer(); requests.Add(new TeleportRequestSingletonBufferElement() { Entity = entity, Destination = destination }); }
public static void RequestImpulse(ISimGameWorldReadWriteAccessor accessor, Entity target, fix2 strength, bool ignoreMass = false) { DirectImpulseRequestData request = new DirectImpulseRequestData() { Target = target, Strength = strength, IgnoreMass = ignoreMass, }; accessor.GetExistingSystem <ApplyImpulseSystem>().RequestImpulseDirect(request); }
public static void RequestDamage(ISimGameWorldReadWriteAccessor accessor, NativeArray <Entity> targets, fix amount, uint effectGroupID = uint.MaxValue) { var sys = accessor.GetExistingSystem <ApplyDamageSystem>(); for (int i = 0; i < targets.Length; i++) { var request = new HealthChangeRequestData() { Amount = -amount, Target = targets[i], EffectGroupID = effectGroupID }; sys.RequestHealthChange(request); } }
public static void RequestRadialImpulse(ISimGameWorldReadWriteAccessor accessor, Entity target, fix strengthMin, fix strengthMax, fix radius, fix2 position, bool ignoreMass = false) { RadialImpulseRequestData request = new RadialImpulseRequestData() { Target = target, Radius = radius, Position = position, IgnoreMass = ignoreMass, StrengthMax = strengthMax, StrengthMin = strengthMin, }; accessor.GetExistingSystem <ApplyImpulseSystem>().RequestImpulseRadial(request); }
public static bool OverlapPoint(ISimGameWorldReadWriteAccessor accessor, fix2 position, NativeList <OverlapPointHit> outHits, Entity ignoreEntity = default) { var physicsSystem = accessor.GetExistingSystem <PhysicsWorldSystem>(); OverlapPointInput pointDistanceInput = OverlapPointInput.Default; pointDistanceInput.Position = (float2)position; if (ignoreEntity != Entity.Null) { pointDistanceInput.Ignore = new IgnoreHit(physicsSystem.GetPhysicsBodyIndex(ignoreEntity)); } return(physicsSystem.PhysicsWorld.OverlapPoint(pointDistanceInput, ref outHits)); }
public static bool CastRay(NativeList <RaycastHit> result, ISimGameWorldReadWriteAccessor accessor, fix2 start, fix2 end, Entity ignoreEntity = default) { var physicsSystem = accessor.GetExistingSystem <PhysicsWorldSystem>(); RaycastInput rayCastInput = RaycastInput.Default; rayCastInput.Start = (float2)start; rayCastInput.End = (float2)end; if (ignoreEntity != Entity.Null) { rayCastInput.Ignore = new IgnoreHit(physicsSystem.GetPhysicsBodyIndex(ignoreEntity)); } return(physicsSystem.PhysicsWorld.CastRay(rayCastInput, ref result)); }
public static bool OverlapAabb(ISimGameWorldReadWriteAccessor accessor, fix2 min, fix2 max, NativeList <Entity> outEntities, Entity ignoreEntity = default) { var physicsSystem = accessor.GetExistingSystem <PhysicsWorldSystem>(); OverlapAabbInput input = OverlapAabbInput.Default; input.Aabb = new Aabb((float2)min, (float2)max); if (ignoreEntity != Entity.Null) { input.Ignore = new IgnoreHit(physicsSystem.GetPhysicsBodyIndex(ignoreEntity)); } NativeList <int> outBodyIndexes = new NativeList <int>(Allocator.Temp); bool hit = physicsSystem.PhysicsWorld.OverlapAabb(input, outBodyIndexes); for (int i = 0; i < outBodyIndexes.Length; i++) { outEntities.Add(physicsSystem.PhysicsWorld.AllBodies[outBodyIndexes[i]].Entity); } return(hit); }