public static void SharedActionCompleted(ICharacter character, VehicleRepairActionState state) { Logger.Info($"Repairing action completed: {state.Vehicle} by {character}", character); var characterPrivateState = PlayerCharacter.GetPrivateState(character); if (characterPrivateState.CurrentActionState != state) { throw new Exception("Should be impossible!"); } characterPrivateState.SetCurrentActionState(null); }
private static void SharedStartAction(ICharacter character, IDynamicWorldObject vehicle) { if (vehicle?.ProtoGameObject is not IProtoVehicle) { return; } var characterPrivateState = PlayerCharacter.GetPrivateState(character); var characterPublicState = PlayerCharacter.GetPublicState(character); if (characterPrivateState.CurrentActionState is VehicleRepairActionState actionState && actionState.Vehicle == vehicle) { // already repairing specified object return; } var selectedHotbarItem = characterPublicState.SelectedItem; if (selectedHotbarItem?.ProtoGameObject is not IProtoItemVehicleRepairKit) { // no tool is selected return; } actionState = new VehicleRepairActionState(character, vehicle, selectedHotbarItem); if (!actionState.CheckIsNeeded()) { // action is not needed Logger.Info($"Repairing is not required: {vehicle} by {character}", character); return; } if (!SharedCheckCanInteract(character, vehicle, true)) { return; } characterPrivateState.SetCurrentActionState(actionState); Logger.Info($"Repairing started: {vehicle} by {character}", character); if (IsClient) { // TODO: we need animation for repairing Instance.CallServer(_ => _.ServerRemote_StartAction(vehicle)); } }