Skip to content

Commit

Permalink
jobs: Enable colliders for all items.
Browse files Browse the repository at this point in the history
  • Loading branch information
freezy committed Oct 5, 2023
1 parent d3eba6f commit 241498b
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 37 deletions.
4 changes: 2 additions & 2 deletions VisualPinball.Unity/VisualPinball.Unity/Game/InsideOfs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private void ClearItems(int itemId)

private void ClearBitIndex(int ballId)
{
var maps = _insideOfs.GetValueArray(Allocator.TempJob);
var maps = _insideOfs.GetValueArray(Allocator.Temp);
var index = GetBitIndex(ballId);
foreach (var ballIndices in maps) {
if (!ballIndices.IsSet(index)) {
Expand All @@ -68,7 +68,7 @@ private int GetBitIndex(int ballId)
return _bitLookup[ballId];
}

var indices = _bitLookup.GetValueArray(Allocator.TempJob);
var indices = _bitLookup.GetValueArray(Allocator.Temp);
for (var i = 0; i < 64; i++) {
if (indices.Contains(i)) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ internal void Register<T>(T item) where T : MonoBehaviour
{
var go = item.gameObject;
var itemId = go.GetInstanceID();
if (_transforms.ContainsKey(itemId)) {
// animation components are always added, sometimes they overlap with the main component (i.e. triggers)
return;
}
_transforms.Add(itemId, go.transform);
_transforms.TryAdd(itemId, go.transform);

switch (item) {
case BumperComponent c: _bumperStates[itemId] = c.CreateState(); break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@

// ReSharper disable InconsistentNaming

using System.Collections.Generic;
using UnityEngine;
using VisualPinball.Engine.VPT.Bumper;

namespace VisualPinball.Unity
{
[AddComponentMenu("Visual Pinball/Collision/Bumper Collider")]
public class BumperColliderComponent : ColliderComponent<BumperData, BumperComponent>, ICollidableComponent
public class BumperColliderComponent : ColliderComponent<BumperData, BumperComponent>
{
#region Data

Expand All @@ -47,12 +46,6 @@ public class BumperColliderComponent : ColliderComponent<BumperData, BumperCompo
protected override IApiColliderGenerator InstantiateColliderApi(Player player)
=> new BumperApi(gameObject, player);


void ICollidableComponent.GetColliders(Player player, List<ICollider> colliders, float margin)
{
InstantiateColliderApi(player).CreateColliders(colliders, margin);
}

public override PhysicsMaterialData PhysicsMaterialData => GetPhysicsMaterialData(scatterAngleDeg: Scatter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace VisualPinball.Unity
{
[DisallowMultipleComponent]
public abstract class ColliderComponent<TData, TMainComponent> : SubComponent<TData, TMainComponent>,
IColliderComponent
IColliderComponent, ICollidableComponent
where TData : ItemData
where TMainComponent : MainComponent<TData>
{
Expand Down Expand Up @@ -457,6 +457,10 @@ private static void DrawAabb(Aabb aabb, bool isSelected)

#endregion

void ICollidableComponent.GetColliders(Player player, List<ICollider> colliders, float margin)
{
InstantiateColliderApi(player).CreateColliders(colliders, margin);
}
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace VisualPinball.Unity
{
[AddComponentMenu("Visual Pinball/Collision/Flipper Collider")]
[HelpURL("https://docs.visualpinball.org/creators-guide/manual/mechanisms/flippers.html")]
public class FlipperColliderComponent : ColliderComponent<FlipperData, FlipperComponent>, ICollidableComponent
public class FlipperColliderComponent : ColliderComponent<FlipperData, FlipperComponent>
{
#region Data

Expand Down Expand Up @@ -162,10 +162,5 @@ public class FlipperColliderComponent : ColliderComponent<FlipperData, FlipperCo

protected override IApiColliderGenerator InstantiateColliderApi(Player player)
=> new FlipperApi(gameObject, player);

void ICollidableComponent.GetColliders(Player player, List<ICollider> colliders, float margin)
{
InstantiateColliderApi(player).CreateColliders(colliders, margin);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

// ReSharper disable InconsistentNaming

using System;
using Unity.Entities;
using UnityEngine;
using VisualPinball.Engine.VPT.HitTarget;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace VisualPinball.Unity
{
[AddComponentMenu("Visual Pinball/Collision/Playfield Collider")]
public class PlayfieldColliderComponent : ColliderComponent<TableData, PlayfieldComponent>, ICollidableComponent
public class PlayfieldColliderComponent : ColliderComponent<TableData, PlayfieldComponent>
{
#region Data

Expand Down Expand Up @@ -56,10 +56,5 @@ public class PlayfieldColliderComponent : ColliderComponent<TableData, Playfield
public override PhysicsMaterialData PhysicsMaterialData => GetPhysicsMaterialData(0, 0);
protected override IApiColliderGenerator InstantiateColliderApi(Player player)
=> new PlayfieldApi(gameObject, player);

void ICollidableComponent.GetColliders(Player player, List<ICollider> colliders, float margin)
{
InstantiateColliderApi(player).CreateColliders(colliders, margin);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
namespace VisualPinball.Unity
{
[AddComponentMenu("Visual Pinball/Collision/Primitive Collider")]
public class PrimitiveColliderComponent : ColliderComponent<PrimitiveData, PrimitiveComponent>, ICollidableComponent
public class PrimitiveColliderComponent : ColliderComponent<PrimitiveData, PrimitiveComponent>
{
#region Data

Expand Down Expand Up @@ -62,10 +62,5 @@ public class PrimitiveColliderComponent : ColliderComponent<PrimitiveData, Primi
public override PhysicsMaterialData PhysicsMaterialData => GetPhysicsMaterialData(Elasticity, ElasticityFalloff, Friction, Scatter, OverwritePhysics);
protected override IApiColliderGenerator InstantiateColliderApi(Player player)
=> new PrimitiveApi(gameObject, player);

void ICollidableComponent.GetColliders(Player player, List<ICollider> colliders, float margin)
{
InstantiateColliderApi(player).CreateColliders(colliders, margin);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private void Awake()
// register at player
GetComponentInParent<Player>().RegisterTrigger(this);

if (GetComponentInChildren<TriggerColliderComponent>() && GetComponentInChildren<TriggerAnimationComponent>() && GetComponentInChildren<TriggerMeshComponent>()) {
if (GetComponentInChildren<TriggerColliderComponent>()) {
GetComponentInParent<PhysicsEngine>().Register(this);
}
}
Expand Down

0 comments on commit 241498b

Please sign in to comment.