public static void ClientDisableConstructionPlacement() { componentObjectPlacementHelper?.SceneObject.Destroy(); componentObjectPlacementHelper = null; ConstructionRelocationSystem.ClientDisableConstructionRelocation(); }
private static IStaticWorldObject ClientFindWorldObjectToRelocate(IEnumerable <IWorldObject> worldObjects) { IStaticWorldObject selectedObject = null; foreach (var worldObject in worldObjects) { if (worldObject is not IStaticWorldObject staticWorldObject || !ConstructionRelocationSystem.SharedIsRelocatable(staticWorldObject)) { continue; } if (selectedObject is not null) { switch (staticWorldObject.ProtoGameObject) { case IProtoObjectFloor: // don't select floor when selected anything else continue; case ProtoObjectDecorationFloor when selectedObject.ProtoGameObject is not IProtoObjectFloor: // don't select decoration when selected anything else except the floor continue; } } selectedObject = staticWorldObject; } return(selectedObject); }
public static void ClientTryStartAction(bool allowReplacingCurrentConstructionAction) { if (!(ClientHotbarSelectedItemManager.SelectedItem?.ProtoGameObject is IProtoItemToolToolbox)) { // no tool is selected return; } if (!ClientInputManager.IsButtonHeld(GameButton.ActionUseCurrentItem)) { // the tool is not currently used return; } var worldObjects = ClientGetObjectsAtCurrentMousePosition(); IStaticWorldObject worldObjectToBuildOrRepair = null, worldObjectToRelocate = null; // find first damaged or incomplete structure there foreach (var worldObject in worldObjects) { if (!(worldObject.ProtoGameObject is IProtoObjectStructure protoObjectStructure)) { continue; } var maxStructurePointsMax = protoObjectStructure.SharedGetStructurePointsMax((IStaticWorldObject)worldObject); var structurePointsCurrent = worldObject.GetPublicState <StaticObjectPublicState>().StructurePointsCurrent; if (structurePointsCurrent < maxStructurePointsMax) { worldObjectToBuildOrRepair = (IStaticWorldObject)worldObject; break; } if (ConstructionRelocationSystem.SharedIsRelocatable((IStaticWorldObject)worldObject)) { worldObjectToRelocate = (IStaticWorldObject)worldObject; } } if (worldObjectToBuildOrRepair is null) { if (!(worldObjectToRelocate is null)) { ConstructionRelocationSystem.ClientStartRelocation(worldObjectToRelocate); } return; } var currentCharacter = Client.Characters.CurrentPlayerCharacter; var privateState = PlayerCharacter.GetPrivateState(currentCharacter); if (privateState.CurrentActionState is ConstructionActionState actionState) { if (!allowReplacingCurrentConstructionAction) { // already performing the action return; } if (ReferenceEquals(actionState.WorldObject, worldObjectToBuildOrRepair)) { // the same object is already building/repairing return; } } SharedStartAction(currentCharacter, worldObjectToBuildOrRepair); }