public BuildingEvent(Construction construction, Construction.Target target, BuildingBlock bb, bool bNeedsValidPlacement) { Builder = Server.GetPlayer(target.player); BuildingPart = new BuildingPart(bb); Construction = construction; Target = target; NeedsValidPlacement = bNeedsValidPlacement; }
public override bool TestTarget(Construction.Target target) { if (!base.TestTarget(target)) { return(false); } return(IsCompatible(target.socket)); }
private void CanBuild(Planner planner, Construction prefab, Construction.Target target) { var oplayer = planner?.GetOwnerPlayer(); if (oplayer != null && TrackedPlayers.ContainsKey(oplayer.userID)) { TrackedPlayers[oplayer.userID].ResetAFKTime(); } }
public void FindMaleSockets(Construction.Target target, List <Socket_Base> sockets) { foreach (Socket_Base allSocket in this.allSockets) { if (allSocket.male && !allSocket.maleDummy && allSocket.TestTarget(target)) { sockets.Add(allSocket); } } }
public bool HasMaleSockets(Construction.Target target) { foreach (Socket_Base allSocket in this.allSockets) { if (allSocket.male && !allSocket.maleDummy && allSocket.TestTarget(target)) { return(true); } } return(false); }
public virtual Construction.Placement DoPlacement(Construction.Target target) { Quaternion quaternion = Quaternion.op_Multiply(Quaternion.LookRotation(target.normal, Vector3.get_up()), Quaternion.Euler(target.rotation)); Vector3 vector3 = Vector3.op_Subtraction(target.position, Quaternion.op_Multiply(quaternion, this.position)); return(new Construction.Placement() { rotation = quaternion, position = vector3 }); }
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 virtual Construction.Placement DoPlacement(Construction.Target target) { Quaternion quaternion = Quaternion.LookRotation(target.normal, Vector3.up) * Quaternion.Euler(target.rotation); Vector3 vector3 = target.position; vector3 = vector3 - (quaternion * this.position); return(new Construction.Placement() { rotation = quaternion, position = vector3 }); }
public override Construction.Placement DoPlacement(Construction.Target target) { if (!Object.op_Implicit((Object)target.entity) || !Object.op_Implicit((Object)((Component)target.entity).get_transform())) { return((Construction.Placement)null); } Vector3 worldPosition = target.GetWorldPosition(); Quaternion worldRotation = target.GetWorldRotation(true); if (this.rotationDegrees > 0) { Construction.Placement placement = new Construction.Placement(); float num1 = float.MaxValue; float num2 = 0.0f; for (int index = 0; index < 360; index += this.rotationDegrees) { Quaternion quaternion1 = Quaternion.Euler(0.0f, (float)(this.rotationOffset + index), 0.0f); Vector3 direction = ((Ray) ref target.ray).get_direction(); Quaternion quaternion2 = worldRotation; Vector3 vector3 = Quaternion.op_Multiply(Quaternion.op_Multiply(quaternion1, quaternion2), Vector3.get_up()); float num3 = Vector3.Angle(direction, vector3); if ((double)num3 < (double)num1) { num1 = num3; num2 = (float)index; } } for (int index = 0; index < 360; index += this.rotationDegrees) { Quaternion quaternion1 = Quaternion.op_Multiply(worldRotation, Quaternion.Inverse(this.rotation)); Quaternion quaternion2 = Quaternion.op_Multiply(Quaternion.op_Multiply(Quaternion.Euler(target.rotation), Quaternion.Euler(0.0f, (float)(this.rotationOffset + index) + num2, 0.0f)), quaternion1); Vector3 vector3 = Quaternion.op_Multiply(quaternion2, this.position); placement.position = Vector3.op_Subtraction(worldPosition, vector3); placement.rotation = quaternion2; if (this.CheckSocketMods(placement)) { return(placement); } } } Construction.Placement placement1 = new Construction.Placement(); Quaternion quaternion = Quaternion.op_Multiply(worldRotation, Quaternion.Inverse(this.rotation)); Vector3 vector3_1 = Quaternion.op_Multiply(quaternion, this.position); placement1.position = Vector3.op_Subtraction(worldPosition, vector3_1); placement1.rotation = quaternion; if (!this.TestRestrictedAngles(worldPosition, worldRotation, target)) { return((Construction.Placement)null); } return(placement1); }
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 override Construction.Placement DoPlacement(Construction.Target target) { if (!target.entity || !target.entity.transform) { return(null); } Vector3 worldPosition = target.GetWorldPosition(); Quaternion worldRotation = target.GetWorldRotation(true); if (this.rotationDegrees > 0) { Construction.Placement placement = new Construction.Placement(); float single = Single.MaxValue; float single1 = 0f; for (int i = 0; i < 360; i += this.rotationDegrees) { Quaternion quaternion = Quaternion.Euler(0f, (float)(this.rotationOffset + i), 0f); Vector3 vector3 = target.ray.direction; Vector3 vector31 = (quaternion * worldRotation) * Vector3.up; float single2 = Vector3.Angle(vector3, vector31); if (single2 < single) { single = single2; single1 = (float)i; } } for (int j = 0; j < 360; j += this.rotationDegrees) { Quaternion quaternion1 = worldRotation * Quaternion.Inverse(this.rotation); Quaternion quaternion2 = Quaternion.Euler(target.rotation); Quaternion quaternion3 = Quaternion.Euler(0f, (float)(this.rotationOffset + j) + single1, 0f); Quaternion quaternion4 = (quaternion2 * quaternion3) * quaternion1; placement.position = worldPosition - (quaternion4 * this.position); placement.rotation = quaternion4; if (this.CheckSocketMods(placement)) { return(placement); } } } Construction.Placement placement1 = new Construction.Placement(); Quaternion quaternion5 = worldRotation * Quaternion.Inverse(this.rotation); placement1.position = worldPosition - (quaternion5 * this.position); placement1.rotation = quaternion5; if (!this.TestRestrictedAngles(worldPosition, worldRotation, target)) { return(null); } return(placement1); }
public override bool TestTarget(Construction.Target target) { if (!base.TestTarget(target)) { return(false); } Socket_Specific_Female socket = target.socket as Socket_Specific_Female; if ((PrefabAttribute)socket == (PrefabAttribute)null) { return(false); } return(socket.CanAccept(this)); }
public override bool TestTarget(Construction.Target target) { if (!base.TestTarget(target)) { return(false); } Socket_Specific_Female socketSpecificFemale = target.socket as Socket_Specific_Female; if (socketSpecificFemale == null) { return(false); } return(socketSpecificFemale.CanAccept(this)); }
object CanBuild(Planner planner, Construction prefab, Construction.Target target) { BasePlayer player = planner.GetOwnerConnection().player as BasePlayer; if (player == null) { return(null); } if (permission.UserHasPermission(player.UserIDString, perm)) { return(null); } return(false); }
public bool TestRestrictedAngles( Vector3 suggestedPos, Quaternion suggestedAng, Construction.Target target) { if (this.restrictPlacementAngle) { Quaternion quaternion = Quaternion.op_Multiply(Quaternion.Euler(0.0f, this.faceAngle, 0.0f), suggestedAng); float num = Vector3Ex.DotDegrees(Vector3Ex.XZ3D(((Ray) ref target.ray).get_direction()), Quaternion.op_Multiply(quaternion, Vector3.get_forward())); if ((double)num > (double)this.angleAllowed * 0.5 || (double)num < (double)this.angleAllowed * -0.5) { return(false); } } return(true); }
private object CheckBuild(Planner planner, Construction prefab, Construction.Target target) { var player = planner.GetOwnerPlayer(); if (player == null) { return(null); } if (_config.blacklist.Contains(prefab.fullName) && !permission.UserHasPermission(player.UserIDString, permissionBypass)) { var msg = string.Format(lang.GetMessage("Restricted", this, player.UserIDString)); player.ChatMessage(msg); return(true); } return(null); }
private bool TestPlacingThroughRock(ref Construction.Placement placement, Construction.Target target) { RaycastHit raycastHit; OBB oBB = new OBB(placement.position, Vector3.one, placement.rotation, this.bounds); Vector3 center = target.player.GetCenter(true); Vector3 vector3 = target.ray.origin; if (Physics.Linecast(center, vector3, 65536, QueryTriggerInteraction.Ignore)) { return(false); } if (Physics.Linecast(vector3, (oBB.Trace(target.ray, out raycastHit, Single.PositiveInfinity) ? raycastHit.point : oBB.ClosestPoint(vector3)), 65536, QueryTriggerInteraction.Ignore)) { return(false); } return(true); }
protected override bool CanConnectToEntity(Construction.Target target) { Elevator elevator; if ((object)(elevator = target.entity as Elevator) != null && elevator.Floor >= MaxFloor) { return(false); } Vector3 vector = target.GetWorldPosition(); Quaternion quaternion = target.GetWorldRotation(true); if (GamePhysics.CheckOBB(new OBB(vector, new Vector3(2f, 0.5f, 2f), quaternion), 2097152)) { return(false); } return(base.CanConnectToEntity(target)); }
object CanBuild(Planner planner, Construction prefab, Construction.Target target) { if (!constructions.ContainsKey(prefab) || constructions[prefab].CanBypass || permission.UserHasPermission(target.player.UserIDString, bypassPerm)) { return(null); } var buildPos = target.entity && target.entity.transform && target.socket ? target.GetWorldPosition() : target.position; if (target.player.IsBuildingBlocked(new OBB(buildPos, default(Quaternion), default(Bounds)))) { target.player.ChatMessage(msg("Building is blocked!", target.player.UserIDString)); return(false); } return(null); }
public bool TestRestrictedAngles(Vector3 suggestedPos, Quaternion suggestedAng, Construction.Target target) { if (this.restrictPlacementAngle) { Quaternion quaternion = Quaternion.Euler(0f, this.faceAngle, 0f) * suggestedAng; float single = target.ray.direction.XZ3D().DotDegrees(quaternion * Vector3.forward); if (single > this.angleAllowed * 0.5f) { return(false); } if (single < this.angleAllowed * -0.5f) { return(false); } } return(true); }
private object CanBuild(Planner plan, Construction construction, Construction.Target target) { if (construction.fullName.Contains(_config.vehicleShortPrefabName)) { Item ownerItem = plan.GetItem(); if (ownerItem != null && ownerItem.info.shortname == _config.vehicleShortPrefabName) { VehicleInfo vehicle = VehicleInfo.FindBySkinID(ownerItem.skin); if (vehicle == null) { return(null); } if (Interface.Oxide.CallHook("CanSpawnVehicle", target.player, ownerItem, plan, construction, target) != null) { return(true); } BaseEntity baseEntity = construction.CreateConstruction(target, true); BaseEntity entity = vehicle.Spawn(baseEntity.transform.position, baseEntity.transform.rotation, target.player, ownerItem); entity.skinID = ownerItem.skin; NextTick(() => { Interface.Oxide.CallHook("OnDoSpawnVehicle", target.player, entity, ownerItem); plan.PayForPlacement(target.player, construction); baseEntity.Kill(); }); if (!string.IsNullOrEmpty(vehicle.placementEffect)) { Effect.server.Run(vehicle.placementEffect, entity, 0u, Vector3.zero, Vector3.zero, null, false); } return(true); } } return(null); }
private object CanBuild(Planner planner, Construction prefab, Construction.Target target) { Vector3 position = target.position.y == 0 ? target.GetWorldPosition() : target.position; //differs if youre attaching the block to an existing building or creating a new building if (planner.GetOwnerPlayer().IPlayer.HasPermission("worldshops.build")) { return(null); } KeyValuePair <WorldShopsSettings.Shop, float>[] distances = _activeShops.Select(x => new KeyValuePair <WorldShopsSettings.Shop, float>(x.Value, Vector3.Distance(x.Key.CenterPoint(), position))).ToArray(); WorldShopsSettings.Shop[] closeShops = distances.Where(x => x.Value < x.Key.BuildingBlockedDistance).OrderBy(x => x.Value).Select(x => x.Key).ToArray(); if (closeShops.Length > 0) { BasePlayer player = planner.GetOwnerPlayer(); player.ChatMessage(this.Lang("ShopTooClose", player, string.Join(", ", closeShops.Select(x => x.WorldName).ToArray()))); return(false); } return(null); }
private bool TestPlacingThroughRock( ref Construction.Placement placement, Construction.Target target) { OBB obb; ((OBB) ref obb).\u002Ector(placement.position, Vector3.get_one(), placement.rotation, this.bounds); Vector3 center = target.player.GetCenter(true); Vector3 origin = ((Ray) ref target.ray).get_origin(); Vector3 vector3_1 = origin; if (Physics.Linecast(center, vector3_1, 65536, (QueryTriggerInteraction)1)) { return(false); } RaycastHit raycastHit; Vector3 vector3_2 = ((OBB) ref obb).Trace(target.ray, ref raycastHit, float.PositiveInfinity) ? ((RaycastHit) ref raycastHit).get_point() : ((OBB) ref obb).ClosestPoint(origin); return(!Physics.Linecast(origin, vector3_2, 65536, (QueryTriggerInteraction)1)); }
private object CheckBuild(Planner planner, Construction prefab, Construction.Target target) { var player = planner.GetOwnerPlayer(); if (player == null) { return(null); } var name = prefab.fullName; var position = target.entity?.transform.position ?? target.position; var check = config.entities > 0.001f; if (IsStash(name)) { if (config.global) { message(player, "Global"); return(false); } if (check && HasBuildingsNearby(position)) { message(player, "Near Entities"); return(false); } } if (check && HasStashesNearby(position)) { message(player, "Near Stashes"); return(false); } return(null); }
private static bool TestPlacingThroughWall( ref Construction.Placement placement, Transform transform, Construction common, Construction.Target target) { Vector3 vector3 = Vector3.op_Subtraction(placement.position, ((Ray) ref target.ray).get_origin()); RaycastHit hit; if (!Physics.Raycast(((Ray) ref target.ray).get_origin(), ((Vector3) ref vector3).get_normalized(), ref hit, ((Vector3) ref vector3).get_magnitude(), 2097152)) { return(true); } StabilityEntity entity = hit.GetEntity() as StabilityEntity; if (Object.op_Inequality((Object)entity, (Object)null) && Object.op_Equality((Object)target.entity, (Object)entity) || (double)((Vector3) ref vector3).get_magnitude() - (double)((RaycastHit) ref hit).get_distance() < 0.200000002980232) { return(true); } Construction.lastPlacementError = "object in placement path"; transform.set_position(((RaycastHit) ref hit).get_point()); transform.set_rotation(placement.rotation); return(false); }
public override bool TestTarget(Construction.Target target) { return(false); }
private object CanBuild(Planner planner, Construction prefab, Construction.Target target) => OnCanBuild(planner.GetOwnerPlayer());
public bool UpdatePlacement( Transform transform, Construction common, ref Construction.Target target) { if (!target.valid) { return(false); } if (!common.canBypassBuildingPermission && !target.player.CanBuild()) { Construction.lastPlacementError = "Player doesn't have permission"; return(false); } List <Socket_Base> list = (List <Socket_Base>)Pool.GetList <Socket_Base>(); common.FindMaleSockets(target, list); foreach (Socket_Base socketBase in list) { Construction.Placement placement = (Construction.Placement)null; if (!Object.op_Inequality((Object)target.entity, (Object)null) || !((PrefabAttribute)target.socket != (PrefabAttribute)null) || !target.entity.IsOccupied(target.socket)) { if (placement == null) { placement = socketBase.DoPlacement(target); } if (placement != null) { if (!socketBase.CheckSocketMods(placement)) { transform.set_position(placement.position); transform.set_rotation(placement.rotation); } else if (!this.TestPlacingThroughRock(ref placement, target)) { transform.set_position(placement.position); transform.set_rotation(placement.rotation); Construction.lastPlacementError = "Placing through rock"; } else if (!Construction.TestPlacingThroughWall(ref placement, transform, common, target)) { transform.set_position(placement.position); transform.set_rotation(placement.rotation); Construction.lastPlacementError = "Placing through wall"; } else if ((double)Vector3.Distance(placement.position, target.player.eyes.position) > (double)common.maxplaceDistance + 1.0) { transform.set_position(placement.position); transform.set_rotation(placement.rotation); Construction.lastPlacementError = "Too far away"; } else { DeployVolume[] all = PrefabAttribute.server.FindAll <DeployVolume>(this.prefabID); if (DeployVolume.Check(placement.position, placement.rotation, all, -1)) { transform.set_position(placement.position); transform.set_rotation(placement.rotation); Construction.lastPlacementError = "Not enough space"; } else if (BuildingProximity.Check(target.player, this, placement.position, placement.rotation)) { transform.set_position(placement.position); transform.set_rotation(placement.rotation); } else if (common.isBuildingPrivilege && !target.player.CanPlaceBuildingPrivilege(placement.position, placement.rotation, common.bounds)) { transform.set_position(placement.position); transform.set_rotation(placement.rotation); Construction.lastPlacementError = "Cannot stack building privileges"; } else { bool flag = target.player.IsBuildingBlocked(placement.position, placement.rotation, common.bounds); if (!common.canBypassBuildingPermission && flag) { transform.set_position(placement.position); transform.set_rotation(placement.rotation); Construction.lastPlacementError = "Building privilege"; } else { target.inBuildingPrivilege = flag; transform.set_position(placement.position); transform.set_rotation(placement.rotation); // ISSUE: cast to a reference type Pool.FreeList <Socket_Base>((List <M0>&) ref list); return(true); } } } } } } // ISSUE: cast to a reference type Pool.FreeList <Socket_Base>((List <M0>&) ref list); return(false); }
public override Construction.Placement DoPlacement(Construction.Target target) { if (!target.entity || !target.entity.transform) { return(null); } if (!CanConnectToEntity(target)) { return(null); } ConstructionSocket constructionSocket = target.socket as ConstructionSocket; Vector3 vector = target.GetWorldPosition(); Quaternion quaternion = target.GetWorldRotation(true); if (constructionSocket != null && !IsCompatible(constructionSocket)) { return(null); } if (rotationDegrees > 0 && (constructionSocket == null || !constructionSocket.restrictPlacementRotation)) { Construction.Placement placement = new Construction.Placement(); float num = float.MaxValue; float num2 = 0f; for (int i = 0; i < 360; i += rotationDegrees) { Quaternion quaternion2 = Quaternion.Euler(0f, rotationOffset + i, 0f); Vector3 direction = target.ray.direction; Vector3 to = quaternion2 * quaternion * Vector3.up; float num3 = Vector3.Angle(direction, to); if (num3 < num) { num = num3; num2 = i; } } for (int j = 0; j < 360; j += rotationDegrees) { Quaternion quaternion3 = quaternion * Quaternion.Inverse(rotation); Quaternion quaternion4 = Quaternion.Euler(target.rotation); Quaternion quaternion5 = Quaternion.Euler(0f, (float)(rotationOffset + j) + num2, 0f); Quaternion quaternion6 = quaternion4 * quaternion5 * quaternion3; Vector3 vector2 = quaternion6 * position; placement.position = vector - vector2; placement.rotation = quaternion6; if (CheckSocketMods(placement)) { return(placement); } } } Construction.Placement placement2 = new Construction.Placement(); Quaternion quaternion7 = quaternion * Quaternion.Inverse(rotation); Vector3 vector3 = quaternion7 * position; placement2.position = vector - vector3; placement2.rotation = quaternion7; if (!TestRestrictedAngles(vector, quaternion, target)) { return(null); } return(placement2); }
protected virtual bool CanConnectToEntity(Construction.Target target) { return(true); }