// Note: this is a recursive method. private void ReadBook(ConnectedPlayer player, int pageToRead = 0) { var playerTile = player.GameObject.RegisterTile(); if (pageToRead >= pagesToRead || pageToRead > 10) { FinishReading(player); return; } StandardProgressActionConfig cfg = new StandardProgressActionConfig( StandardProgressActionType.Construction, false, false ); StandardProgressAction.Create(cfg, ReadPage).ServerStartProgress( playerTile, timeToReadPage, player.GameObject ); void ReadPage() { readerProgress[player]++; SoundManager.PlayNetworkedAtPos(pageturnSfx.PickRandom(), playerTile.WorldPositionServer, sourceObj: player.GameObject); Chat.AddExamineMsgFromServer(player.GameObject, remarks.PickRandom()); ReadBook(player, readerProgress[player]); } }
/// <summary> /// Handles the interaction request for uncuffing serverside /// </summary> public void ServerPerformInteraction(ContextMenuApply interaction) { var handcuffSlots = interaction.TargetObject.GetComponent <DynamicItemStorage>().OrNull()?.GetNamedItemSlots(NamedSlot.handcuffs) .Where(x => x.IsEmpty == false).ToList(); if (handcuffSlots == null) { return; } //Somehow has no cuffs but has cuffed effect, force uncuff if (handcuffSlots.Count == 0) { Uncuff(); return; } foreach (var handcuffSlot in handcuffSlots) { var restraint = handcuffSlot.Item.GetComponent <Restraint>(); if (restraint == null) { continue; } var progressConfig = new StandardProgressActionConfig(StandardProgressActionType.Uncuff); StandardProgressAction.Create(progressConfig, Uncuff) .ServerStartProgress(interaction.TargetObject.RegisterTile(), restraint.RemoveTime * (handcuffSlots.Count / 2f), interaction.Performer); //Only need to do it once break; } }
public override void ServerPerformInteraction(TileApply interaction) { if (!interaction.UsedObject.RegisterTile().Matrix.IsPassableAt(interaction.TargetCellPos, true, true, null, excludeTiles)) { return; } StandardProgressActionConfig cfg = new StandardProgressActionConfig(StandardProgressActionType.Construction, false, false, false); var x = StandardProgressAction.Create(cfg, () => { PlayerScript playerScript; if (interaction.UsedObject.TryGetComponent(out playerScript)) { List <TileType> excludeTiles = new List <TileType>() { TileType.Table }; if (playerScript.registerTile.Matrix.IsPassableAt(interaction.TargetCellPos, true, true, null, excludeTiles)) { playerScript.PlayerSync.SetPosition(interaction.WorldPositionTarget); } } else { var transformComp = interaction.UsedObject.GetComponent <CustomNetTransform>(); if (transformComp != null) { transformComp.AppearAtPositionServer(interaction.WorldPositionTarget); } } }).ServerStartProgress(interaction.UsedObject.RegisterTile(), 3.0f, interaction.Performer); }
// Note: this is a recursive method. private void ReadBook(ConnectedPlayer player, int pageToRead = 0) { if (pageToRead >= pagesToRead || pageToRead > 10) { FinishReading(player); return; } StandardProgressActionConfig cfg = new StandardProgressActionConfig( StandardProgressActionType.Construction, false, false ); StandardProgressAction.Create(cfg, ReadPage).ServerStartProgress( player.GameObject.RegisterTile(), timeToReadPage, player.GameObject ); void ReadPage() { readerProgress[player]++; // TODO: play random page-turning sound => pageturn1.ogg || pageturn2.ogg || pageturn3.ogg string remark = remarks[Random.Range(0, remarks.Length)]; Chat.AddExamineMsgFromServer(player.GameObject, remark); ReadBook(player, readerProgress[player]); } }
private StandardProgressAction(StandardProgressActionConfig progressActionConfig, Action onCompletion, Action <ActionInterruptionType> onInterruption) { this.progressActionConfig = progressActionConfig; this.onCompletion = onCompletion; this.onInterruption = onInterruption; }
public void ServerPerformInteraction(MouseDrop interaction) { StandardProgressActionConfig cfg = new StandardProgressActionConfig(StandardProgressActionType.Construction, false, false, false); StandardProgressAction.Create(cfg, () => { if (interaction.UsedObject.TryGetComponent <PlayerScript>(out var playerScript)) { playerScript.PlayerSync.SetPosition(gameObject.WorldPosServer()); }
protected void StartUnwrapAction(GameObject performer) { var cfg = new StandardProgressActionConfig( StandardProgressActionType.Restrain); Chat.AddActionMsgToChat( performer, string.Format(originatorUnwrapText, gameObject.ExpensiveName()), string.Format(othersUnwrapText, performer.ExpensiveName(), gameObject.ExpensiveName())); StandardProgressAction.Create(cfg, UnWrap) .ServerStartProgress(ActionTarget.Object(performer.RegisterTile()), timeToUnwrap, performer); }
protected override void Wrap(GameObject performer, WrappingPaper paper) { var cfg = new StandardProgressActionConfig( StandardProgressActionType.Restrain); Chat.AddActionMsgToChat( performer, string.Format(actionTextOriginator, gameObject.ExpensiveName(), paper.gameObject.ExpensiveName()), string.Format(actionTextOthers, performer.ExpensiveName(), gameObject.ExpensiveName(), paper.gameObject.ExpensiveName())); StandardProgressAction.Create( cfg, () => FinishWrapping(paper) ).ServerStartProgress(ActionTarget.Object(performer.RegisterTile()), wrapTime, performer); }
public override void ServerPerformInteraction(TileApply interaction) { if (!interaction.UsedObject.RegisterTile().Matrix.IsPassableAtOneMatrixOneTile(interaction.TargetCellPos, true, true, null, excludeTiles)) { return; } StandardProgressActionConfig cfg = new StandardProgressActionConfig(StandardProgressActionType.Construction, false, false, false); var x = StandardProgressAction.Create(cfg, () => { PlayerScript playerScript; if (interaction.UsedObject.TryGetComponent(out playerScript)) { List <TileType> excludeTiles = new List <TileType>() { TileType.Table }; if (playerScript.registerTile.Matrix.IsPassableAtOneMatrixOneTile(interaction.TargetCellPos, true, true, null, excludeTiles)) { playerScript.PlayerSync.SetPosition(interaction.WorldPositionTarget); } } else { var transformComp = interaction.UsedObject.GetComponent <CustomNetTransform>(); if (transformComp != null) { transformComp.AppearAtPositionServer(interaction.WorldPositionTarget); } } if (canBreakOnClimb == false) { return; } if (DMMath.Prob(breakChance) && interaction.UsedObject.TryGetComponent <RegisterPlayer>(out var victim)) { interaction.BasicTile.SpawnOnDestroy.SpawnAt(SpawnDestination.At(interaction.WorldPositionTarget)); victim.ServerStun(stunTimeOnBreak); _ = SoundManager.PlayNetworkedAtPosAsync(soundOnBreak, interaction.WorldPositionTarget); Chat.AddActionMsgToChat(interaction.UsedObject, $"Your weight pushes onto the {interaction.BasicTile.DisplayName} and you break it and fall through it", $"{interaction.UsedObject.ExpensiveName()} falls through the {interaction.BasicTile.DisplayName} as it breaks from their weight."); victim.PlayerScript.playerHealth.ApplyDamageAll(interaction.Performer, damageOnBreak, AttackType.Melee, DamageType.Brute); interaction.TileChangeManager.MetaTileMap.RemoveTileWithlayer(interaction.TargetCellPos, interaction.BasicTile.LayerType); } }).ServerStartProgress(interaction.UsedObject.RegisterTile(), 3.0f, interaction.Performer);
private void TryEmagConsole(HandApply interaction) { if (beenEmagged) { Chat.AddExamineMsgFromServer(interaction.Performer, "The shuttle has already been hacked!"); return; } Chat.AddActionMsgToChat(interaction.Performer, $"You attempt to hack the shuttle console, this will take around {timeToHack} seconds", $"{interaction.Performer.ExpensiveName()} starts hacking the shuttle console"); var cfg = new StandardProgressActionConfig(StandardProgressActionType.Restrain); StandardProgressAction.Create( cfg, () => FinishHack(interaction) ).ServerStartProgress(ActionTarget.Object(registerTile), timeToHack, interaction.Performer); }
// TODO This was copied from somewhere. Where? void StartStoringPlayer(MouseDrop interaction) { List <LayerType> excludeObjects = new List <LayerType>() { LayerType.Objects }; Vector3Int targetObjectLocalPosition = interaction.TargetObject.RegisterTile().LocalPosition; Vector3Int targetObjectWorldPos = interaction.TargetObject.WorldPosServer().CutToInt(); if (!interaction.UsedObject.RegisterTile().Matrix.IsPassableAt(targetObjectLocalPosition, true, excludeLayers: excludeObjects)) { return; } void StoringPlayer() { PlayerScript playerScript; if (interaction.UsedObject.TryGetComponent(out playerScript)) { if (playerScript.registerTile.Matrix.IsPassableAt(targetObjectLocalPosition, true, excludeLayers: excludeObjects)) { playerScript.PlayerSync.SetPosition(targetObjectWorldPos); } } else { var transformComp = interaction.UsedObject.GetComponent <CustomNetTransform>(); if (transformComp != null) { transformComp.AppearAtPositionServer(targetObjectWorldPos); } } StorePlayer(interaction); } StandardProgressActionConfig cfg = new StandardProgressActionConfig(StandardProgressActionType.Construction, false, false, false); StandardProgressAction.Create(cfg, StoringPlayer).ServerStartProgress(interaction.UsedObject.RegisterTile(), 2, interaction.Performer); }
/// <summary> /// Handles the interaction request for uncuffing serverside /// </summary> public void ServerPerformInteraction(ContextMenuApply interaction) { var handcuffs = interaction.TargetObject.GetComponent <ItemStorage>().GetNamedItemSlot(NamedSlot.handcuffs).ItemObject; if (handcuffs == null) { return; } var restraint = handcuffs.GetComponent <Restraint>(); if (restraint == null) { return; } var ProgressConfig = new StandardProgressActionConfig(StandardProgressActionType.Uncuff); StandardProgressAction.Create(ProgressConfig, Uncuff) .ServerStartProgress(interaction.TargetObject.RegisterTile(), restraint.RemoveTime, interaction.Performer); }
// TODO This was copied from somewhere. Where? void StartStoringPlayer(MouseDrop interaction) { Vector3Int targetObjectLocalPosition = interaction.TargetObject.RegisterTile().LocalPosition; Vector3Int targetObjectWorldPos = interaction.TargetObject.WorldPosServer().CutToInt(); // We check if there's nothing in the way, like another player or a directional window. if (interaction.UsedObject.RegisterTile().Matrix.IsPassableAtOneMatrixOneTile(targetObjectLocalPosition, true, context: gameObject) == false) { return; } // Runs when the progress action is complete. void StoringPlayer() { PlayerScript playerScript; if (interaction.UsedObject.TryGetComponent(out playerScript)) { if (playerScript.registerTile.Matrix.IsPassableAtOneMatrixOneTile(targetObjectLocalPosition, true, context: gameObject)) { playerScript.PlayerSync.SetPosition(targetObjectWorldPos); } } else { var transformComp = interaction.UsedObject.GetComponent <CustomNetTransform>(); if (transformComp != null) { transformComp.AppearAtPositionServer(targetObjectWorldPos); } } StorePlayer(interaction); } StandardProgressActionConfig cfg = new StandardProgressActionConfig(StandardProgressActionType.Construction, false, false, false); StandardProgressAction.Create(cfg, StoringPlayer).ServerStartProgress(interaction.UsedObject.RegisterTile(), 2, interaction.Performer); }
/// <summary> /// Just like Create, but will auto-interrupt progress if the welder runs out of fuel. /// </summary> /// <param name="progressActionConfig"></param> /// <param name="onCompletion"></param> /// <returns></returns> public static StandardProgressAction CreateForWelder(StandardProgressActionConfig progressActionConfig, Action onCompletion, Welder welder) { return(new StandardProgressAction(progressActionConfig, onCompletion, welder)); }
/// <summary> /// Creates a new instance of a progress action with the indicated configuration and /// completion action. /// </summary> /// <param name="progressActionConfig">config</param> /// <param name="onCompletion">action to invoke server-side on successful completion (not invoked when interrupted)</param> /// <returns></returns> public static StandardProgressAction Create(StandardProgressActionConfig progressActionConfig, Action onCompletion) { return(new StandardProgressAction(progressActionConfig, onCompletion)); }
private StandardProgressAction(StandardProgressActionConfig progressActionConfig, Action onCompletion, Welder welder = null) { this.progressActionConfig = progressActionConfig; this.onCompletion = onCompletion; this.welder = welder; }
/// <summary> /// Creates a new instance of a progress action with the indicated configuration and /// completion action. /// </summary> /// <param name="progressActionConfig">config</param> /// <param name="onCompletion">action to invoke server-side on successful completion (not invoked when interrupted)</param> /// <param name="onInterrupted">action to invoke server-side when interrupted</param> /// <returns></returns> public static StandardProgressAction Create(StandardProgressActionConfig progressActionConfig, Action onCompletion, Action <ActionInterruptionType> onInterrupted) { return(new StandardProgressAction(progressActionConfig, onCompletion, onInterrupted)); }