Merge branch 'master' into 2020-04-28-tool-component

This commit is contained in:
zumorica
2020-05-11 12:24:43 +02:00
114 changed files with 3532 additions and 531 deletions

View File

@@ -0,0 +1,22 @@
using System;
using Content.Shared.GameObjects.Components.Sound;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Random;
namespace Content.Shared.Audio
{
public static class AudioHelpers{
/// <summary>
/// Returns a random pitch.
/// </summary>
public static AudioParams WithVariation(float amplitude)
{
var scale = (float)(IoCManager.Resolve<IRobustRandom>().NextGaussian(1, amplitude));
return AudioParams.Default.WithPitchScale(scale);
}
}
}

View File

@@ -1,23 +1,36 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using Content.Shared.Maps;
using Robust.Shared.ContentPack;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
namespace Content.Shared
{
public class EntryPoint : GameShared
{
// If you want to change your codebase's language, do it here.
private const string Culture = "en-US";
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager;
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
public override void PreInit()
{
IoCManager.InjectDependencies(this);
// Default to en-US.
_localizationManager.LoadCulture(new CultureInfo(Culture));
}
public override void Init()
{
IoCManager.InjectDependencies(this);
}
public override void PostInit()

View File

@@ -0,0 +1,57 @@
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components.UserInterface;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Gravity
{
public class SharedGravityGeneratorComponent: Component
{
public override string Name => "GravityGenerator";
public override uint? NetID => ContentNetIDs.GRAVITY_GENERATOR;
/// <summary>
/// Sent to the server to set whether the generator should be on or off
/// </summary>
[Serializable, NetSerializable]
public class SwitchGeneratorMessage : BoundUserInterfaceMessage
{
public bool On;
public SwitchGeneratorMessage(bool on)
{
On = on;
}
}
/// <summary>
/// Sent to the server when requesting the status of the generator
/// </summary>
[Serializable, NetSerializable]
public class GeneratorStatusRequestMessage : BoundUserInterfaceMessage
{
public GeneratorStatusRequestMessage()
{
}
}
[Serializable, NetSerializable]
public class GeneratorState : BoundUserInterfaceState
{
public bool On;
public GeneratorState(bool on)
{
On = on;
}
}
[Serializable, NetSerializable]
public enum GravityGeneratorUiKey
{
Key
}
}
}

View File

@@ -42,5 +42,7 @@
public const uint PAPER = 1037;
public const uint REAGENT_INJECTOR = 1038;
public const uint GHOST = 1039;
public const uint MICROWAVE = 1040;
public const uint GRAVITY_GENERATOR = 1041;
}
}

View File

@@ -51,13 +51,17 @@ namespace Content.Server.GameObjects.EntitySystems
var rayResults = _physicsManager.IntersectRayWithPredicate(coords.MapId, ray, dir.Length, predicate, true);
if(!rayResults.DidHitObject || (insideBlockerValid && rayResults.DidHitObject && (rayResults.HitPos - otherCoords).Length < 1f))
{
_mapManager.TryFindGridAt(coords, out var mapGrid);
var srcPos = mapGrid.MapToGrid(coords);
var destPos = new GridCoordinates(otherCoords, mapGrid);
if (srcPos.InRange(_mapManager, destPos, range))
if (_mapManager.TryFindGridAt(coords, out var mapGrid) && mapGrid != null)
{
return true;
var srcPos = mapGrid.MapToGrid(coords);
var destPos = new GridCoordinates(otherCoords, mapGrid);
if (srcPos.InRange(_mapManager, destPos, range))
{
return true;
}
}
}
return false;
}

View File

@@ -5,8 +5,7 @@ namespace Content.Shared.Input
[KeyFunctions]
public static class ContentKeyFunctions
{
public static readonly BoundKeyFunction UseOrAttack = "UseOrAttack";
public static readonly BoundKeyFunction Attack = "Attack";
public static readonly BoundKeyFunction WideAttack = "WideAttack";
public static readonly BoundKeyFunction ActivateItemInHand = "ActivateItemInHand";
public static readonly BoundKeyFunction ActivateItemInWorld = "ActivateItemInWorld"; // default action on world entity
public static readonly BoundKeyFunction Drop = "Drop";
@@ -16,6 +15,8 @@ namespace Content.Shared.Input
public static readonly BoundKeyFunction OpenContextMenu = "OpenContextMenu";
public static readonly BoundKeyFunction OpenCraftingMenu = "OpenCraftingMenu";
public static readonly BoundKeyFunction OpenInventoryMenu = "OpenInventoryMenu";
public static readonly BoundKeyFunction SmartEquipBackpack = "SmartEquipBackpack";
public static readonly BoundKeyFunction SmartEquipBelt = "SmartEquipBelt";
public static readonly BoundKeyFunction OpenTutorial = "OpenTutorial";
public static readonly BoundKeyFunction SwapHands = "SwapHands";
public static readonly BoundKeyFunction ThrowItemInHand = "ThrowItemInHand";
@@ -24,5 +25,7 @@ namespace Content.Shared.Input
public static readonly BoundKeyFunction OpenEntitySpawnWindow = "OpenEntitySpawnWindow";
public static readonly BoundKeyFunction OpenSandboxWindow = "OpenSandboxWindow";
public static readonly BoundKeyFunction OpenTileSpawnWindow = "OpenTileSpawnWindow";
public static readonly BoundKeyFunction TakeScreenshot = "TakeScreenshot";
public static readonly BoundKeyFunction TakeScreenshotNoUI = "TakeScreenshotNoUI";
}
}

View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using Content.Shared.Prototypes.Kitchen;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Shared.Kitchen
{
public class RecipeManager
{
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
#pragma warning restore 649
public List<FoodRecipePrototype> Recipes { get; private set; }
public void Initialize()
{
Recipes = new List<FoodRecipePrototype>();
foreach (var item in _prototypeManager.EnumeratePrototypes<FoodRecipePrototype>())
{
Recipes.Add(item);
}
Recipes.Sort(new RecipeComparer());
}
private class RecipeComparer : Comparer<FoodRecipePrototype>
{
public override int Compare(FoodRecipePrototype x, FoodRecipePrototype y)
{
if (x == null || y == null)
{
return 0;
}
return -x.IngredientsReagents.Count.CompareTo(y.IngredientsReagents.Count);
}
}
}
}

View File

@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using Content.Shared.Chemistry;
using Content.Shared.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.GameObjects.Components.UserInterface;
namespace Content.Shared.Kitchen
{
public class SharedMicrowaveComponent : Component
{
public override string Name => "Microwave";
public override uint? NetID => ContentNetIDs.MICROWAVE;
[Serializable, NetSerializable]
public class MicrowaveStartCookMessage : BoundUserInterfaceMessage
{
public MicrowaveStartCookMessage()
{
}
}
[Serializable, NetSerializable]
public class MicrowaveEjectMessage : BoundUserInterfaceMessage
{
public MicrowaveEjectMessage()
{
}
}
[Serializable, NetSerializable]
public class MicrowaveEjectSolidIndexedMessage : BoundUserInterfaceMessage
{
public EntityUid EntityID;
public MicrowaveEjectSolidIndexedMessage(EntityUid entityID)
{
EntityID = entityID;
}
}
[Serializable, NetSerializable]
public class MicrowaveVaporizeReagentIndexedMessage : BoundUserInterfaceMessage
{
public Solution.ReagentQuantity ReagentQuantity;
public MicrowaveVaporizeReagentIndexedMessage(Solution.ReagentQuantity reagentQuantity)
{
ReagentQuantity = reagentQuantity;
}
}
[Serializable, NetSerializable]
public class MicrowaveSelectCookTimeMessage : BoundUserInterfaceMessage
{
public uint newCookTime;
public MicrowaveSelectCookTimeMessage(uint inputTime)
{
newCookTime = inputTime;
}
}
}
[NetSerializable, Serializable]
public class MicrowaveUpdateUserInterfaceState : BoundUserInterfaceState
{
public readonly IReadOnlyList<Solution.ReagentQuantity> ReagentsReagents;
public readonly List<EntityUid> ContainedSolids;
public MicrowaveUpdateUserInterfaceState(IReadOnlyList<Solution.ReagentQuantity> reagents, List<EntityUid> solids)
{
ReagentsReagents = reagents;
ContainedSolids = solids;
}
}
[Serializable, NetSerializable]
public enum MicrowaveVisualState
{
Idle,
Cooking
}
[NetSerializable, Serializable]
public enum MicrowaveUiKey
{
Key
}
}

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Shared.Prototypes.Kitchen
{
/// <summary>
/// A recipe for space microwaves.
/// </summary>
[Prototype("microwaveMealRecipe")]
public class FoodRecipePrototype : IPrototype, IIndexedPrototype
{
private string _id;
private string _name;
private string _result;
private int _cookTime;
private Dictionary<string, int> _ingsReagents;
private Dictionary<string, int> _ingsSolids;
public string Name => Loc.GetString(_name);
public string ID => _id;
public string Result => _result;
public int CookTime => _cookTime;
public IReadOnlyDictionary<string, int> IngredientsReagents => _ingsReagents;
public IReadOnlyDictionary<string, int> IngredientsSolids => _ingsSolids;
public void LoadFrom(YamlMappingNode mapping)
{
var serializer = YamlObjectSerializer.NewReader(mapping);
serializer.DataField(ref _id, "id", string.Empty);
serializer.DataField(ref _name, "name", string.Empty);
serializer.DataField(ref _result, "result", string.Empty);
serializer.DataField(ref _ingsReagents, "reagents", new Dictionary<string, int>());
serializer.DataField(ref _ingsSolids, "solids", new Dictionary<string, int>());
serializer.DataField(ref _cookTime, "time", 5);
}
}
}

View File

@@ -138,7 +138,7 @@ namespace Content.Shared
public string GamemodeTitle;
public TimeSpan RoundDuration;
public uint PlayerCount;