public static void RaiseOnObjectEnteredPortal(PortalInstance portal, WarppableObject obj) { if (ObjectEnteredPortal != null) { ObjectEnteredPortal.Invoke(portal, obj); } }
public static void RaiseOnObjectExitedPortal(PortalInstance portal, WarppableObject obj, bool crossedThePortal) { if (ObjectExitedPortal != null) { ObjectExitedPortal.Invoke(portal, obj, crossedThePortal); } }
private void OnTriggerExit(Collider other) { Debug.Log("OnTriggerEnd"); if (other == null) { return; } WarppableObject warppableObject = other.GetComponent <WarppableObject>(); if (warppableObject == null) { return; } if (!_warppableObjectsInside.Contains(warppableObject)) { return; } bool exitedFromBack = !IsWarppableObjectInPositionZ(warppableObject); _warppableObjectsInside.Remove(warppableObject); Events.RaiseOnObjectExitedPortal(this, warppableObject, exitedFromBack); }
private void OnTriggerEnter(Collider other) { Debug.Log("OnTriggerEnter"); if (other == null) { return; } WarppableObject warppableObject = other.GetComponent <WarppableObject>(); if (warppableObject == null) { return; } if (_warppableObjectsInside.Contains(warppableObject)) { return; } if (!IsWarppableObjectInPositionZ(warppableObject)) { return; // the object did not enter from forward } _warppableObjectsInside.Add(warppableObject); Events.RaiseOnObjectEnteredPortal(this, warppableObject); }
public PositionAndRotation GetWarpableObjectLocalTransforms(WarppableObject obj) { PositionAndRotation posAndRot = new PositionAndRotation(); posAndRot.lPosition = _axis.InverseTransformPoint(obj.transform.position); // Getting the position in the axis of the portal posAndRot.lRotation = Quaternion.Inverse(_axis.rotation) * obj.transform.rotation; // finding local rotation - we are taking global rotaion and substracting it by Axis rotation. // in rotations, substraction is inverse return(posAndRot); }
private WarpableObjectSet GetWormHoleSet(WarppableObject obj) { foreach (var set in warpableObjectSets) { if (set._warpObject == obj) { return(set); } } return(null); }
private void OnObjectEnterWarp(PortalInstance portal, WarppableObject warppableObj) { Debug.Log("OnObjectEnterWarp 1"); Utils.Assert(portal != null && warppableObj != null); if (!portalSet.IsWormHoleOpen()) { return; } if (GetWormHoleSet(warppableObj) != null) { return; } warppableObj.CloneObject(); warpableObjectSets.Add(new WarpableObjectSet(portal, portalSet.GetOtherPortal(portal), warppableObj)); }
private void OnObjectExitedWarp(PortalInstance portal, WarppableObject warppableObj, bool crossedTheWormHole) { Utils.Assert(portal != null && warppableObj != null); if (!portalSet.IsWormHoleOpen()) { return; } WarpableObjectSet warpableObjectSet = GetWormHoleSet(warppableObj); if (warpableObjectSet == null) { Debug.LogWarning("Check this!"); return; } if (crossedTheWormHole) { warpableObjectSet._warpObject.SwapWithClone(); } warpableObjectSet._warpObject.DestroyClone(); warpableObjectSets.Remove(warpableObjectSet); }
public void Start() { obj = GetComponent <WarppableObject>(); }
public WarpableObjectSet(PortalInstance portalA, PortalInstance portalB, WarppableObject warpableObj) { _portalA = portalA; _portalB = portalB; _warpObject = warpableObj; }
public bool IsWarppableObjectInPositionZ(WarppableObject obj) { return(GetWarpableObjectLocalTransforms(obj).lPosition.z > 0); }