public override bool CanConnect( Vector3 position, Quaternion rotation, Socket_Base socket, Vector3 socketPosition, Quaternion socketRotation) { if (!base.CanConnect(position, rotation, socket, socketPosition, socketRotation)) { return(false); } Matrix4x4 matrix4x4_1 = Matrix4x4.TRS(position, rotation, Vector3.get_one()); Matrix4x4 matrix4x4_2 = Matrix4x4.TRS(socketPosition, socketRotation, Vector3.get_one()); if ((double)Vector3.Distance(((Matrix4x4) ref matrix4x4_1).MultiplyPoint3x4(this.worldPosition), ((Matrix4x4) ref matrix4x4_2).MultiplyPoint3x4(socket.worldPosition)) > 0.00999999977648258) { return(false); } Vector3 vector3_1 = ((Matrix4x4) ref matrix4x4_1).MultiplyVector(Quaternion.op_Multiply(this.worldRotation, Vector3.get_forward())); Vector3 vector3_2 = ((Matrix4x4) ref matrix4x4_2).MultiplyVector(Quaternion.op_Multiply(socket.worldRotation, Vector3.get_forward())); float num = Vector3.Angle(vector3_1, vector3_2); if (this.male && this.female) { num = Mathf.Min(num, Vector3.Angle(Vector3.op_UnaryNegation(vector3_1), vector3_2)); } if (socket.male && socket.female) { num = Mathf.Min(num, Vector3.Angle(vector3_1, Vector3.op_UnaryNegation(vector3_2))); } return((double)num <= 1.0); }
public override bool CanConnect(Vector3 position, Quaternion rotation, Socket_Base socket, Vector3 socketPosition, Quaternion socketRotation) { if (!base.CanConnect(position, rotation, socket, socketPosition, socketRotation)) { return(false); } Matrix4x4 matrix4x = Matrix4x4.TRS(position, rotation, Vector3.one); Matrix4x4 matrix4x2 = Matrix4x4.TRS(socketPosition, socketRotation, Vector3.one); Vector3 a = matrix4x.MultiplyPoint3x4(worldPosition); Vector3 b = matrix4x2.MultiplyPoint3x4(socket.worldPosition); if (Vector3.Distance(a, b) > 0.01f) { return(false); } Vector3 vector = matrix4x.MultiplyVector(worldRotation * Vector3.forward); Vector3 vector2 = matrix4x2.MultiplyVector(socket.worldRotation * Vector3.forward); float num = Vector3.Angle(vector, vector2); if (male && female) { num = Mathf.Min(num, Vector3.Angle(-vector, vector2)); } if (socket.male && socket.female) { num = Mathf.Min(num, Vector3.Angle(vector, -vector2)); } if (num > 1f) { return(false); } return(true); }
public override bool CanConnect(Vector3 position, Quaternion rotation, Socket_Base socket, Vector3 socketPosition, Quaternion socketRotation) { if (!base.CanConnect(position, rotation, socket, socketPosition, socketRotation)) { return(false); } Matrix4x4 matrix4x4 = Matrix4x4.TRS(position, rotation, Vector3.one); Matrix4x4 matrix4x41 = Matrix4x4.TRS(socketPosition, socketRotation, Vector3.one); if (Vector3.Distance(matrix4x4.MultiplyPoint3x4(this.worldPosition), matrix4x41.MultiplyPoint3x4(socket.worldPosition)) > 0.01f) { return(false); } Vector3 vector3 = matrix4x4.MultiplyVector(this.worldRotation * Vector3.forward); Vector3 vector31 = matrix4x41.MultiplyVector(socket.worldRotation * Vector3.forward); float single = Vector3.Angle(vector3, vector31); if (this.male && this.female) { single = Mathf.Min(single, Vector3.Angle(-vector3, vector31)); } if (socket.male && socket.female) { single = Mathf.Min(single, Vector3.Angle(vector3, -vector31)); } if (single > 1f) { return(false); } return(true); }
public virtual bool IsCompatible(Socket_Base socket) { if ((PrefabAttribute)socket == (PrefabAttribute)null || !socket.male && !this.male || !socket.female && !this.female) { return(false); } return(((object)socket).GetType() == ((object)this).GetType()); }
public virtual bool CanConnect( Vector3 position, Quaternion rotation, Socket_Base socket, Vector3 socketPosition, Quaternion socketRotation) { return(this.IsCompatible(socket)); }
public void Setup(BaseEntity owner, Socket_Base socket) { this.owner = owner; this.socket = socket; if (socket.monogamous) { capacity = 1; } }
private static BuildingProximity.ProximityInfo GetProximity( Construction construction1, Vector3 position1, Quaternion rotation1, Construction construction2, Vector3 position2, Quaternion rotation2) { BuildingProximity.ProximityInfo proximityInfo = new BuildingProximity.ProximityInfo(); proximityInfo.hit = false; proximityInfo.connection = false; proximityInfo.line = (Line)null; proximityInfo.sqrDist = float.MaxValue; for (int index1 = 0; index1 < construction1.allSockets.Length; ++index1) { ConstructionSocket allSocket1 = construction1.allSockets[index1] as ConstructionSocket; if (!((PrefabAttribute)allSocket1 == (PrefabAttribute)null)) { for (int index2 = 0; index2 < construction2.allSockets.Length; ++index2) { Socket_Base allSocket2 = construction2.allSockets[index2]; if (allSocket1.CanConnect(position1, rotation1, allSocket2, position2, rotation2)) { proximityInfo.connection = true; return(proximityInfo); } } } } if (!proximityInfo.connection && construction1.allProximities.Length != 0) { for (int index1 = 0; index1 < construction1.allSockets.Length; ++index1) { ConstructionSocket allSocket = construction1.allSockets[index1] as ConstructionSocket; if (!((PrefabAttribute)allSocket == (PrefabAttribute)null) && allSocket.socketType == ConstructionSocket.Type.Wall) { Vector3 selectPivot1 = allSocket.GetSelectPivot(position1, rotation1); for (int index2 = 0; index2 < construction2.allProximities.Length; ++index2) { Vector3 selectPivot2 = construction2.allProximities[index2].GetSelectPivot(position2, rotation2); Line line; ((Line) ref line).\u002Ector(selectPivot1, selectPivot2); Vector3 vector3 = Vector3.op_Subtraction((Vector3)line.point1, (Vector3)line.point0); float sqrMagnitude = ((Vector3) ref vector3).get_sqrMagnitude(); if ((double)sqrMagnitude < (double)proximityInfo.sqrDist) { proximityInfo.hit = true; proximityInfo.line = line; proximityInfo.sqrDist = sqrMagnitude; } } } } } return(proximityInfo); }
public override bool CanConnect(Vector3 position, Quaternion rotation, Socket_Base socket, Vector3 socketPosition, Quaternion socketRotation) { if (!base.CanConnect(position, rotation, socket, socketPosition, socketRotation)) { return(false); } OBB selectBounds = base.GetSelectBounds(position, rotation); return(selectBounds.Intersects(socket.GetSelectBounds(socketPosition, socketRotation))); }
public override bool IsCompatible(Socket_Base socket) { if (!base.IsCompatible(socket)) { return(false); } ConstructionSocket constructionSocket = socket as ConstructionSocket; return(!((PrefabAttribute)constructionSocket == (PrefabAttribute)null) && constructionSocket.socketType != ConstructionSocket.Type.None && (this.socketType != ConstructionSocket.Type.None && constructionSocket.socketType == this.socketType)); }
public static void AddLinks(this List <EntityLink> links, BaseEntity entity, Socket_Base[] sockets) { for (int i = 0; i < (int)sockets.Length; i++) { Socket_Base socketBase = sockets[i]; EntityLink entityLink = Pool.Get <EntityLink>(); entityLink.Setup(entity, socketBase); links.Add(entityLink); } }
public override bool CanConnect(Vector3 position, Quaternion rotation, Socket_Base socket, Vector3 socketPosition, Quaternion socketRotation) { if (!base.CanConnect(position, rotation, socket, socketPosition, socketRotation)) { return(false); } Vector3 vector = Matrix4x4.TRS(position, rotation, Vector3.one).MultiplyPoint3x4(worldPosition); return(!GamePhysics.CheckOBB(new OBB(vector, new Vector3(2f, 0.5f, 2f), rotation), 2097152)); }
public void FindMaleSockets(Construction.Target target, List <Socket_Base> sockets) { Socket_Base[] socketBaseArray = this.allSockets; for (int i = 0; i < (int)socketBaseArray.Length; i++) { Socket_Base socketBase = socketBaseArray[i]; if (socketBase.male && !socketBase.maleDummy && socketBase.TestTarget(target)) { sockets.Add(socketBase); } } }
public bool HasMaleSockets(Construction.Target target) { Socket_Base[] socketBaseArray = this.allSockets; for (int i = 0; i < (int)socketBaseArray.Length; i++) { Socket_Base socketBase = socketBaseArray[i]; if (socketBase.male && !socketBase.maleDummy && socketBase.TestTarget(target)) { return(true); } } return(false); }
public static void AddLinks( this List <EntityLink> links, BaseEntity entity, Socket_Base[] sockets) { for (int index = 0; index < sockets.Length; ++index) { Socket_Base socket = sockets[index]; EntityLink entityLink = (EntityLink)Pool.Get <EntityLink>(); entityLink.Setup(entity, socket); links.Add(entityLink); } }
public virtual bool IsCompatible(Socket_Base socket) { if (socket == null) { return(false); } if (!socket.male && !this.male) { return(false); } if (!socket.female && !this.female) { return(false); } return(socket.GetType() == base.GetType()); }
public override bool IsCompatible(Socket_Base socket) { if (!base.IsCompatible(socket)) { return(false); } ConstructionSocket constructionSocket = socket as ConstructionSocket; if (constructionSocket == null) { return(false); } if (constructionSocket.socketType == ConstructionSocket.Type.None || this.socketType == ConstructionSocket.Type.None) { return(false); } if (constructionSocket.socketType != this.socketType) { return(false); } return(true); }
public void EnterPool() { this.owner = (BaseEntity)null; this.socket = (Socket_Base)null; this.capacity = int.MaxValue; }
public bool UpdatePlacement(Transform transform, Construction common, ref Construction.Target target) { bool flag; if (!target.valid) { return(false); } if (!common.canBypassBuildingPermission && !target.player.CanBuild()) { Construction.lastPlacementError = "Player doesn't have permission"; return(false); } List <Socket_Base> list = Pool.GetList <Socket_Base>(); common.FindMaleSockets(target, list); List <Socket_Base> .Enumerator enumerator = list.GetEnumerator(); try { while (enumerator.MoveNext()) { Socket_Base current = enumerator.Current; Construction.Placement placement = null; if (target.entity != null && target.socket != null && target.entity.IsOccupied(target.socket)) { continue; } if (placement == null) { placement = current.DoPlacement(target); } if (placement == null) { continue; } if (!current.CheckSocketMods(placement)) { transform.position = placement.position; transform.rotation = placement.rotation; } else if (!this.TestPlacingThroughRock(ref placement, target)) { transform.position = placement.position; transform.rotation = placement.rotation; Construction.lastPlacementError = "Placing through rock"; } else if (!Construction.TestPlacingThroughWall(ref placement, transform, common, target)) { transform.position = placement.position; transform.rotation = placement.rotation; Construction.lastPlacementError = "Placing through wall"; } else if (Vector3.Distance(placement.position, target.player.eyes.position) <= common.maxplaceDistance + 1f) { DeployVolume[] deployVolumeArray = PrefabAttribute.server.FindAll <DeployVolume>(this.prefabID); if (DeployVolume.Check(placement.position, placement.rotation, deployVolumeArray, -1)) { transform.position = placement.position; transform.rotation = placement.rotation; Construction.lastPlacementError = "Not enough space"; } else if (BuildingProximity.Check(target.player, this, placement.position, placement.rotation)) { transform.position = placement.position; transform.rotation = placement.rotation; } else if (!common.isBuildingPrivilege || target.player.CanPlaceBuildingPrivilege(placement.position, placement.rotation, common.bounds)) { bool flag1 = target.player.IsBuildingBlocked(placement.position, placement.rotation, common.bounds); if (common.canBypassBuildingPermission || !flag1) { target.inBuildingPrivilege = flag1; transform.position = placement.position; transform.rotation = placement.rotation; Pool.FreeList <Socket_Base>(ref list); flag = true; return(flag); } else { transform.position = placement.position; transform.rotation = placement.rotation; Construction.lastPlacementError = "Building privilege"; } } else { transform.position = placement.position; transform.rotation = placement.rotation; Construction.lastPlacementError = "Cannot stack building privileges"; } } else { transform.position = placement.position; transform.rotation = placement.rotation; Construction.lastPlacementError = "Too far away"; } } Pool.FreeList <Socket_Base>(ref list); return(false); } finally { ((IDisposable)enumerator).Dispose(); } return(flag); }
public void EnterPool() { this.owner = null; this.socket = null; this.capacity = 2147483647; }
public void EnterPool() { owner = null; socket = null; capacity = int.MaxValue; }