public CollisionFlags Move(Vector3 motion) { CollisionFlags collisionFlag; CCDesc cCDesc; CCDesc sCurrentMovingCCDesc = CCDesc.s_CurrentMovingCCDesc; try { CCDesc.s_CurrentMovingCCDesc = this; if (!object.ReferenceEquals(this.AssignedHitManager, null)) { this.AssignedHitManager.Clear(); } collisionFlag = this.m_Collider.Move(motion); } finally { if (!sCurrentMovingCCDesc) { cCDesc = null; } else { cCDesc = sCurrentMovingCCDesc; } CCDesc.s_CurrentMovingCCDesc = cCDesc; } return(collisionFlag); }
public bool SimpleMove(Vector3 speed) { bool flag; CCDesc cCDesc; CCDesc sCurrentMovingCCDesc = CCDesc.s_CurrentMovingCCDesc; try { CCDesc.s_CurrentMovingCCDesc = this; flag = this.m_Collider.SimpleMove(speed); } finally { if (!sCurrentMovingCCDesc) { cCDesc = null; } else { cCDesc = sCurrentMovingCCDesc; } CCDesc.s_CurrentMovingCCDesc = cCDesc; } return(flag); }
private void DoSetup() { if (!this.didSetup && Application.isPlaying) { this.didSetup = true; (this.ccdesc = base.GetComponent <CCDesc>()).AssignedHitManager = this.hitManager = new CCDesc.HitManager(); } }
public Initialization(CCTotemPole totemPole, CCDesc figurePrefab, float minHeight, float maxHeight, float initialHeight, float bottomBufferUnits) { this.totemPole = totemPole; this.figurePrefab = figurePrefab; this.minHeight = minHeight; this.maxHeight = maxHeight; this.initialHeight = initialHeight; this.bottomBufferUnits = bottomBufferUnits; this.nonDefault = true; }
internal void DestroyCCDesc(ref CCDesc CCDesc) { if (CCDesc) { CCDesc cCDesc = CCDesc; CCDesc = null; this.ExecuteBinding(cCDesc, false); UnityEngine.Object.Destroy(cCDesc.gameObject); } }
public bool SmudgeTo(Vector3 worldSkinnedBottom) { if (!this.Exists) { return(false); } Vector3 position = base.transform.position; if (position != worldSkinnedBottom) { Vector3 vector3; Vector3 vector7; Vector3 vector2 = worldSkinnedBottom - position; CCDesc cCDesc = base.totemicObject.CCDesc; if (cCDesc == null) { return(false); } vector3.x = vector3.z = 0f; vector3.y = (cCDesc.effectiveHeight * 0.5f) - cCDesc.radius; Vector3 center = cCDesc.center; Vector3 vector5 = cCDesc.OffsetToWorld(center - vector3); Vector3 vector6 = cCDesc.OffsetToWorld(center + vector3); Vector3 vector8 = cCDesc.OffsetToWorld(center + new Vector3(cCDesc.skinnedRadius, 0f, 0f)) - cCDesc.worldCenter; float magnitude = vector8.magnitude; float distance = vector2.magnitude; float num3 = 1f / distance; vector7.x = vector2.x * num3; vector7.y = vector2.y * num3; vector7.z = vector2.z * num3; int layerMask = 0; int layer = base.gameObject.layer; for (int i = 0; i < 0x20; i++) { if (!Physics.GetIgnoreLayerCollision(layer, i)) { layerMask |= ((int)1) << i; } } if (Physics.CapsuleCast(vector5, vector6, magnitude, vector7, distance, layerMask)) { return(false); } Transform transform = base.totemicObject.CCDesc.transform; transform.position += vector2; for (int j = 0; j < base.totemicObject.Configuration.numRequiredTotemicFigures; j++) { Transform transform2 = base.totemicObject.TotemicFigures[j].CCDesc.transform; transform2.position += vector2; } this.BindPositions(new CCTotem.PositionPlacement(base.totemicObject.CCDesc.worldSkinnedBottom, base.totemicObject.CCDesc.worldSkinnedTop, base.totemicObject.CCDesc.transform.position, base.totemicObject.Configuration.poleExpandedHeight)); } return(true); }
private CCDesc InstantiateCCDesc(Vector3 worldBottom, string name) { CCTotem.Initialization configuration = this.Configuration.totem; CCDesc cCDesc = (CCDesc)UnityEngine.Object.Instantiate(configuration.figurePrefab, worldBottom, Quaternion.identity); if (!string.IsNullOrEmpty(name)) { cCDesc.name = name; } cCDesc.gameObject.hideFlags = HideFlags.NotEditable; cCDesc.detectCollisions = false; return(cCDesc); }
internal void ExecuteBinding(CCDesc CCDesc, bool Bind) { if (CCDesc && !object.ReferenceEquals(this.ConfigurationBinder, null)) { try { this.ConfigurationBinder(Bind, CCDesc, this.Tag); } catch (Exception exception) { Debug.LogException(exception, this); } } }
public bool SimpleMove(Vector3 speed) { bool flag; CCDesc desc = s_CurrentMovingCCDesc; try { s_CurrentMovingCCDesc = this; flag = this.m_Collider.SimpleMove(speed); } finally { s_CurrentMovingCCDesc = (desc == null) ? null : desc; } return(flag); }
private static void DestroyCCDesc(CCTotemPole ScriptOwner, ref CCDesc CCDesc) { if (!ScriptOwner) { CCDesc cCDesc = CCDesc; CCDesc = null; if (cCDesc) { UnityEngine.Object.Destroy(cCDesc.gameObject); } } else { ScriptOwner.DestroyCCDesc(ref CCDesc); } }
public static CCHitDispatch GetHitDispatch(CCDesc CCDesc) { if (!CCDesc) { return null; } if (!object.ReferenceEquals(CCDesc.AssignedHitManager, null)) { return CCDesc.GetComponent<CCHitDispatch>(); } CCHitDispatch component = CCDesc.GetComponent<CCHitDispatch>(); if (component) { return component; } return CCDesc.gameObject.AddComponent<CCHitDispatch>(); }
public static CCHitDispatch GetHitDispatch(CCDesc CCDesc) { if (CCDesc == null) { return(null); } if (!object.ReferenceEquals(CCDesc.AssignedHitManager, null)) { return(CCDesc.GetComponent <CCHitDispatch>()); } CCHitDispatch component = CCDesc.GetComponent <CCHitDispatch>(); if (component != null) { return(component); } return(CCDesc.gameObject.AddComponent <CCHitDispatch>()); }
private void DoSetup() { if (!this.didSetup) { if (!Application.isPlaying) { return; } this.didSetup = true; CCDesc component = base.GetComponent <CCDesc>(); CCDesc cCDesc = component; this.ccdesc = component; CCDesc.HitManager hitManager = new CCDesc.HitManager(); CCDesc.HitManager hitManager1 = hitManager; this.hitManager = hitManager; cCDesc.AssignedHitManager = hitManager1; } }
public Hit(ControllerColliderHit ControllerColliderHit) { this.CharacterController = ControllerColliderHit.controller; CCDesc desc = CCDesc.s_CurrentMovingCCDesc; if ((desc == null) || (desc.collider != this.CharacterController)) { this.CCDesc = this.CharacterController.GetComponent <CCDesc>(); } else { this.CCDesc = desc; } this.Collider = ControllerColliderHit.collider; this.Point = ControllerColliderHit.point; this.Normal = ControllerColliderHit.normal; this.MoveDirection = ControllerColliderHit.moveDirection; this.MoveLength = ControllerColliderHit.moveLength; }
public Hit(UnityEngine.ControllerColliderHit ControllerColliderHit) { this.CharacterController = ControllerColliderHit.controller; CCDesc sCurrentMovingCCDesc = CCDesc.s_CurrentMovingCCDesc; if (!sCurrentMovingCCDesc || sCurrentMovingCCDesc.collider != this.CharacterController) { this.CCDesc = this.CharacterController.GetComponent <CCDesc>(); } else { this.CCDesc = sCurrentMovingCCDesc; } this.Collider = ControllerColliderHit.collider; this.Point = ControllerColliderHit.point; this.Normal = ControllerColliderHit.normal; this.MoveDirection = ControllerColliderHit.moveDirection; this.MoveLength = ControllerColliderHit.moveLength; }
public CollisionFlags Move(Vector3 motion) { CollisionFlags flags; CCDesc desc = s_CurrentMovingCCDesc; try { s_CurrentMovingCCDesc = this; if (!object.ReferenceEquals(this.AssignedHitManager, null)) { this.AssignedHitManager.Clear(); } flags = this.m_Collider.Move(motion); } finally { s_CurrentMovingCCDesc = (desc == null) ? null : desc; } return(flags); }
public void Create() { float configuration = this.Configuration.totem.initialHeight; this.Expansion = this.Contraction.ExpansionForValue(configuration); Vector3 script = this.Script.transform.position + this.Configuration.figureOriginOffsetBottom; this.CCDesc = this.InstantiateCCDesc(script, "__TotemPole"); if (this.Script) { this.Script.ExecuteBinding(this.CCDesc, true); } for (int i = 0; i < this.Configuration.numRequiredTotemicFigures; i++) { this.InstantiateTotemicFigure(script, this.TotemicFigures[i]); } this.Point.Bottom = this.TotemicFigures[0].BottomOrigin; CCTotem.Ends <CCTotem.TotemicFigure> totemicFigureEnds = this.TotemicFigureEnds; this.Point.Top = totemicFigureEnds.Top.TopOrigin; this.CCDesc.ModifyHeight(this.Point.Top.y - this.Point.Bottom.y, false); }
private void OnHit(ref CCDesc.Hit hit) { Vector3 vector3 = new Vector3(); Vector3 normal = hit.Normal; Vector3 moveDirection = hit.MoveDirection; if (normal.y > 0f && normal.y > this._groundNormal.y && moveDirection.y < 0f) { Vector3 point = hit.Point; vector3.x = point.x - this.movement.lastHitPoint.x; vector3.y = point.y - this.movement.lastHitPoint.y; vector3.z = point.z - this.movement.lastHitPoint.z; if ((this._lastGroundNormal.x != 0f || this._lastGroundNormal.y != 0f || this._lastGroundNormal.z != 0f) && vector3.x * vector3.x + vector3.y * vector3.y + vector3.z * vector3.z <= 0.001f) { this._groundNormal = this._lastGroundNormal; } else { this._groundNormal = normal; } this.movingPlatform.hitPlatform = hit.Collider.transform; this.movement.hitPoint = point; Vector3 vector31 = new Vector3(); this.movement.frameVelocity = vector31; } }
private static bool OnHit(CCDesc.HitManager HitManager, ref CCDesc.Hit hit) { CCMotor tag = (CCMotor)HitManager.Tag; if (CCMotor.ccmotor_debug && !(hit.Collider is TerrainCollider)) { UnityEngine.Debug.Log(string.Format("{{\"ccmotor\":{{\"hit\":{{\"point\":[{0},{1},{2}],\"normal\":[{3},{4},{5}]}},\"dir\":[{6},{7},{8}],\"move\":{9},\"obj\":{10}}}}}", new object[] { hit.Point.x, hit.Point.y, hit.Point.z, hit.Normal.x, hit.Normal.y, hit.Normal.z, hit.MoveDirection.x, hit.MoveDirection.y, hit.MoveDirection.z, hit.MoveLength, hit.Collider }), hit.GameObject); } tag.OnHit(ref hit); return true; }
private static void OnConfigurationBinding(bool Bind, CCDesc CCDesc, object Tag) { CCHitDispatch hitDispatch = CCHitDispatch.GetHitDispatch(CCDesc); if (hitDispatch) { CCDesc.HitManager hits = hitDispatch.Hits; if (!object.ReferenceEquals(hits, null)) { if (Bind) { hits.Tag = Tag; hits.OnHit += CCMotor.Callbacks.HitFilter; } else if (object.ReferenceEquals(hits.Tag, Tag)) { hits.Tag = null; hits.OnHit -= CCMotor.Callbacks.HitFilter; } } } if (Bind) { CCDesc.Tag = Tag; if (!CCDesc.GetComponent<CCTotemicFigure>()) { IDRemote component = CCDesc.GetComponent<IDRemote>(); if (!component) { component = CCDesc.gameObject.AddComponent<IDRemoteDefault>(); } component.idMain = ((CCMotor)Tag).idMain; CCDesc.detectCollisions = true; } } else if (object.ReferenceEquals(CCDesc.Tag, Tag)) { CCDesc.Tag = null; } }
public bool SmudgeTo(Vector3 worldSkinnedBottom) { Vector3 vector3 = new Vector3(); Vector3 vector31 = new Vector3(); if (!this.Exists) { return(false); } Vector3 vector32 = base.transform.position; if (vector32 == worldSkinnedBottom) { return(true); } Vector3 vector33 = worldSkinnedBottom - vector32; CCDesc cCDesc = this.totemicObject.CCDesc; if (!cCDesc) { return(false); } float single = 0f; float single1 = single; vector3.z = single; vector3.x = single1; vector3.y = cCDesc.effectiveHeight * 0.5f - cCDesc.radius; Vector3 vector34 = cCDesc.center; Vector3 world = cCDesc.OffsetToWorld(vector34 - vector3); Vector3 world1 = cCDesc.OffsetToWorld(vector34 + vector3); Vector3 world2 = cCDesc.OffsetToWorld(vector34 + new Vector3(cCDesc.skinnedRadius, 0f, 0f)) - cCDesc.worldCenter; float single2 = world2.magnitude; float single3 = vector33.magnitude; float single4 = 1f / single3; vector31.x = vector33.x * single4; vector31.y = vector33.y * single4; vector31.z = vector33.z * single4; int num = 0; int num1 = base.gameObject.layer; for (int i = 0; i < 32; i++) { if (!Physics.GetIgnoreLayerCollision(num1, i)) { num = num | 1 << (i & 31 & 31); } } if (Physics.CapsuleCast(world, world1, single2, vector31, single3, num)) { return(false); } Transform transforms = this.totemicObject.CCDesc.transform; transforms.position = transforms.position + vector33; for (int j = 0; j < this.totemicObject.Configuration.numRequiredTotemicFigures; j++) { Transform cCDesc1 = this.totemicObject.TotemicFigures[j].CCDesc.transform; cCDesc1.position = cCDesc1.position + vector33; } Vector3 cCDesc2 = this.totemicObject.CCDesc.worldSkinnedBottom; Vector3 cCDesc3 = this.totemicObject.CCDesc.worldSkinnedTop; Vector3 cCDesc4 = this.totemicObject.CCDesc.transform.position; CCTotem.Configuration configuration = this.totemicObject.Configuration; this.BindPositions(new CCTotem.PositionPlacement(cCDesc2, cCDesc3, cCDesc4, configuration.poleExpandedHeight)); return(true); }
private void DoSetup() { if (!this.didSetup) { if (!Application.isPlaying) { return; } this.didSetup = true; CCDesc component = base.GetComponent<CCDesc>(); CCDesc cCDesc = component; this.ccdesc = component; CCDesc.HitManager hitManager = new CCDesc.HitManager(); CCDesc.HitManager hitManager1 = hitManager; this.hitManager = hitManager; cCDesc.AssignedHitManager = hitManager1; } }
public Configuration(ref CCTotem.Initialization totem) { if (!totem.figurePrefab) { throw new ArgumentException("figurePrefab was missing", "totem"); } this.totem = totem; this.totemMinHeight = totem.minHeight; this.totemMaxHeight = totem.maxHeight; this.totemBottomBufferUnits = totem.bottomBufferUnits; if (this.totemMinHeight >= this.totemMaxHeight) { throw new ArgumentException("maxHeight is less than or equal to minHeight", "totem"); } if (Mathf.Approximately(this.totemBottomBufferUnits, 0f)) { this.totemBottomBufferUnits = 0f; } else if (this.totemBottomBufferUnits < 0f) { throw new ArgumentException("bottomBufferPercent must not be less than zero", "totem"); } CCDesc cCDesc = totem.figurePrefab; this.figureSkinWidth = cCDesc.skinWidth; this.figure2SkinWidth = this.figureSkinWidth + this.figureSkinWidth; this.figureRadius = cCDesc.radius; this.figureSkinnedRadius = this.figureRadius + this.figureSkinWidth; this.figureDiameter = this.figureRadius + this.figureRadius; this.figureSkinnedDiameter = this.figureSkinnedRadius + this.figureSkinnedRadius; this.figureHeight = cCDesc.height; if (this.figureHeight <= this.figureDiameter) { throw new ArgumentException("The CCDesc(CharacterController) Prefab is a sphere, not a capsule. Thus cannot be expanded on the totem pole", "totem"); } this.figureSkinnedHeight = this.figureHeight + this.figure2SkinWidth; if (this.figureSkinnedHeight > this.totemMinHeight && !Mathf.Approximately(this.totemMinHeight, this.figureSkinnedHeight)) { throw new ArgumentException("minHeight is too small. It must be at least the size of the CCDesc(CharacterController) prefab's [height+(skinWidth*2)]", "totem"); } this.figureSlideHeight = this.figureSkinnedHeight - this.figureSkinnedDiameter; if (this.figureSlideHeight <= 0f) { throw new ArgumentException("The CCDesc(CharacterController) Prefab has limited height availability. Thus cannot be expanded on the totem pole", "totem"); } this.figureFixedHeight = this.figureSkinnedHeight - this.figureSlideHeight; this.poleTopBufferAmount = this.figureSkinnedRadius; this.poleBottomBufferUnitSize = this.figureSlideHeight * 0.5f; this.poleBottomBufferAmount = this.poleBottomBufferUnitSize * this.totemBottomBufferUnits; if (this.poleBottomBufferAmount > this.figureSlideHeight) { if (!Mathf.Approximately(this.poleBottomBufferAmount, this.figureSlideHeight)) { throw new ArgumentException("The bottomBuffer was too large and landed outside of sliding height area of the capsule", "totem"); } this.poleBottomBufferAmount = this.figureSlideHeight; this.totemBottomBufferUnits = this.figureSlideHeight / this.poleBottomBufferUnitSize; } this.poleBottomBufferHeight = this.figureSkinnedRadius + this.poleBottomBufferAmount; this.poleMostContractedHeightPossible = this.figureSkinnedHeight + this.poleBottomBufferAmount; if (this.poleMostContractedHeightPossible > this.totemMinHeight) { if (!Mathf.Approximately(this.poleMostContractedHeightPossible, this.totemMinHeight)) { throw new ArgumentException("bottomBufferPercent value is too high with the current setup, results in contracted height greater than totem.minHeight.", "totem"); } this.totemMinHeight = this.poleMostContractedHeightPossible; } this.poleContractedHeight = Mathf.Max(this.poleMostContractedHeightPossible, this.totemMinHeight); this.poleContractedHeightFromMostContractedHeightPossible = this.poleContractedHeight - this.poleMostContractedHeightPossible; this.poleExpandedHeight = Mathf.Max(this.poleContractedHeight, this.totemMaxHeight); this.poleExpandedHeightFromMostContractedHeightPossible = this.poleExpandedHeight - this.poleMostContractedHeightPossible; if (Mathf.Approximately(this.poleContractedHeightFromMostContractedHeightPossible, this.poleExpandedHeightFromMostContractedHeightPossible)) { throw new ArgumentException("minHeight and maxHeight were too close to eachother to provide reliable contraction/expansion calculations.", "totem"); } if (this.poleContractedHeightFromMostContractedHeightPossible < 0f || this.poleExpandedHeightFromMostContractedHeightPossible < this.poleContractedHeightFromMostContractedHeightPossible) { throw new ArgumentException("Calculation error with current configuration.", "totem"); } this.poleFixedLength = this.poleBottomBufferHeight + this.poleTopBufferAmount; this.poleExpansionLength = this.poleExpandedHeight - this.poleFixedLength; this.numSlidingTotemicFigures = Mathf.CeilToInt(this.poleExpansionLength / this.figureSlideHeight); if (this.numSlidingTotemicFigures < 1) { throw new ArgumentException("The current configuration of the CCTotem resulted in no need for more than one CCDesc(CharacterController), thus rejecting usage..", "totem"); } this.poleMostExpandedHeightPossible = this.poleFixedLength + (float)this.numSlidingTotemicFigures * this.figureSlideHeight; this.numRequiredTotemicFigures = 1 + this.numSlidingTotemicFigures; if (this.numRequiredTotemicFigures > 8) { throw new ArgumentOutOfRangeException("totem", (object)this.numRequiredTotemicFigures, string.Concat("The current configuration of the CCTotem resulted in more than the max number of TotemicFigure's allowed :", 8)); } Vector3 vector3 = cCDesc.center; this.figureOriginOffsetCenter = new Vector3(0f - vector3.x, 0f - vector3.y, 0f - vector3.z); this.figureOriginOffsetBottom = new Vector3(this.figureOriginOffsetCenter.x, 0f - (vector3.y - this.figureSkinnedHeight / 2f), this.figureOriginOffsetCenter.z); this.figureOriginOffsetTop = new Vector3(this.figureOriginOffsetCenter.x, 0f - (vector3.y + this.figureSkinnedHeight / 2f), this.figureOriginOffsetCenter.z); }