Merge branches '20-06-08-submodule', 'virtualize-netids', 'betterConstruction' and '20-06-08-addcomp-default'
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Client.GameObjects.Components.Construction;
|
||||
using Content.Client.Interfaces.GameObjects;
|
||||
using Content.Shared.Construction;
|
||||
using Content.Shared.GameObjects.Components.Interactable;
|
||||
using Robust.Client.Graphics;
|
||||
@@ -48,7 +49,7 @@ namespace Content.Client.Construction
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
Placement = (PlacementManager) IoCManager.Resolve<IPlacementManager>();
|
||||
Placement.PlacementCanceled += OnPlacementCanceled;
|
||||
Placement.PlacementChanged += OnPlacementChanged;
|
||||
|
||||
Title = "Construction";
|
||||
|
||||
@@ -95,7 +96,7 @@ namespace Content.Client.Construction
|
||||
TextAlign = Label.AlignMode.Center,
|
||||
Text = "Build!",
|
||||
Disabled = true,
|
||||
ToggleMode = false
|
||||
ToggleMode = true
|
||||
};
|
||||
EraseButton = new Button
|
||||
{
|
||||
@@ -108,7 +109,7 @@ namespace Content.Client.Construction
|
||||
hSplitContainer.AddChild(guide);
|
||||
Contents.AddChild(hSplitContainer);
|
||||
|
||||
BuildButton.OnPressed += OnBuildPressed;
|
||||
BuildButton.OnToggled += OnBuildToggled;
|
||||
EraseButton.OnToggled += OnEraseToggled;
|
||||
SearchBar.OnTextChanged += OnTextEntered;
|
||||
RecipeList.OnItemSelected += OnItemSelected;
|
||||
@@ -123,7 +124,7 @@ namespace Content.Client.Construction
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
Placement.PlacementCanceled -= OnPlacementCanceled;
|
||||
Placement.PlacementChanged -= OnPlacementChanged;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,37 +227,49 @@ namespace Content.Client.Construction
|
||||
PopulateTree(string.IsNullOrWhiteSpace(str) ? null : str.ToLowerInvariant());
|
||||
}
|
||||
|
||||
void OnBuildPressed(BaseButton.ButtonEventArgs args)
|
||||
void OnBuildToggled(BaseButton.ButtonToggledEventArgs args)
|
||||
{
|
||||
var prototype = (ConstructionPrototype) RecipeList.Selected.Metadata;
|
||||
if (prototype == null)
|
||||
if (args.Pressed)
|
||||
{
|
||||
return;
|
||||
var prototype = (ConstructionPrototype) RecipeList.Selected.Metadata;
|
||||
if (prototype == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (prototype.Type == ConstructionType.Item)
|
||||
{
|
||||
Owner.TryStartItemConstruction(prototype.ID);
|
||||
BuildButton.Pressed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Placement.BeginHijackedPlacing(
|
||||
new PlacementInformation
|
||||
{
|
||||
IsTile = false,
|
||||
PlacementOption = prototype.PlacementMode
|
||||
},
|
||||
new ConstructionPlacementHijack(prototype, Owner));
|
||||
}
|
||||
|
||||
if (prototype.Type != ConstructionType.Structure)
|
||||
else
|
||||
{
|
||||
// In-hand attackby doesn't exist so this is the best alternative.
|
||||
var loc = Owner.Owner.GetComponent<ITransformComponent>().GridPosition;
|
||||
Owner.SpawnGhost(prototype, loc, Direction.North);
|
||||
return;
|
||||
Placement.Clear();
|
||||
}
|
||||
|
||||
var hijack = new ConstructionPlacementHijack(prototype, Owner);
|
||||
var info = new PlacementInformation
|
||||
{
|
||||
IsTile = false,
|
||||
PlacementOption = prototype.PlacementMode,
|
||||
};
|
||||
|
||||
|
||||
Placement.BeginHijackedPlacing(info, hijack);
|
||||
BuildButton.Pressed = args.Pressed;
|
||||
}
|
||||
|
||||
private void OnEraseToggled(BaseButton.ButtonToggledEventArgs args)
|
||||
{
|
||||
var hijack = new ConstructionPlacementHijack(null, Owner);
|
||||
Placement.ToggleEraserHijacked(hijack);
|
||||
if (args.Pressed) Placement.Clear();
|
||||
Placement.ToggleEraserHijacked(new ConstructionPlacementHijack(null, Owner));
|
||||
EraseButton.Pressed = args.Pressed;
|
||||
}
|
||||
|
||||
private void OnPlacementChanged(object sender, EventArgs e)
|
||||
{
|
||||
BuildButton.Pressed = false;
|
||||
EraseButton.Pressed = false;
|
||||
}
|
||||
|
||||
void PopulatePrototypeList()
|
||||
@@ -363,11 +376,6 @@ namespace Content.Client.Construction
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPlacementCanceled(object sender, EventArgs e)
|
||||
{
|
||||
EraseButton.Pressed = false;
|
||||
}
|
||||
|
||||
private static int ComparePrototype(ConstructionPrototype x, ConstructionPrototype y)
|
||||
{
|
||||
return String.Compare(x.Name, y.Name, StringComparison.Ordinal);
|
||||
|
||||
@@ -114,6 +114,12 @@ namespace Content.Client.GameObjects.Components.Construction
|
||||
SendNetworkMessage(msg);
|
||||
}
|
||||
|
||||
public void TryStartItemConstruction(string prototypeName)
|
||||
{
|
||||
var msg = new TryStartItemConstructionMessage(prototypeName);
|
||||
SendNetworkMessage(msg);
|
||||
}
|
||||
|
||||
public void ClearGhost(int ghostId)
|
||||
{
|
||||
if (Ghosts.TryGetValue(ghostId, out var ghost))
|
||||
|
||||
Reference in New Issue
Block a user