Gitlab to Gitea Migration
This commit is contained in:
62
Objects/StockpileObject.cs
Normal file
62
Objects/StockpileObject.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
// Copyright (c) Strange Loop Games. All rights reserved.
|
||||
// See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Eco.Mods.TechTree
|
||||
{
|
||||
using Eco.Gameplay.Components;
|
||||
using Eco.Gameplay.Objects;
|
||||
using Gameplay.Components.Auth;
|
||||
using Gameplay.Players;
|
||||
using Shared.Math;
|
||||
using Gameplay.Items;
|
||||
using Shared.Serialization;
|
||||
using World = Eco.World.World;
|
||||
using World.Blocks;
|
||||
using Shared.Networking;
|
||||
|
||||
public partial class StockpileItem : WorldObjectItem<StockpileObject>
|
||||
{
|
||||
public override bool TryPlaceObject(Player player, Vector3i position, Quaternion rotation)
|
||||
{
|
||||
Vector3i startPosition = position - new Vector3i((int)(StockpileComponent.Dimensions.x / 2f), 1, (int)(StockpileComponent.Dimensions.z / 2f));
|
||||
foreach (var offset in StockpileComponent.Dimensions.XZ.XYIter())
|
||||
{
|
||||
var worldPos = startPosition + offset.X_Z();
|
||||
if (!World.GetBlock(worldPos).Is<Solid>())
|
||||
{
|
||||
player.SendTemporaryErrorLoc("Stockpile requires solid ground to be placed on.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return base.TryPlaceObject(player, position, rotation);
|
||||
}
|
||||
}
|
||||
|
||||
[Serialized]
|
||||
[RequireComponent(typeof(PropertyAuthComponent))]
|
||||
[RequireComponent(typeof(PublicStorageComponent))]
|
||||
[RequireComponent(typeof(StockpileComponent))]
|
||||
[RequireComponent(typeof(LinkComponent))]
|
||||
public partial class StockpileObject : WorldObject
|
||||
{
|
||||
public override string FriendlyName { get { return "Stockpile"; } }
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
var storage = this.GetComponent<PublicStorageComponent>();
|
||||
storage.Initialize(StockpileComponent.Dimensions.x * StockpileComponent.Dimensions.z);
|
||||
storage.Storage.AddRestriction(new CarriedRestriction()); // restrict stockpiles to carried items.
|
||||
|
||||
this.GetComponent<PropertyAuthComponent>().Initialize(AuthModeType.Inherited);
|
||||
this.GetComponent<LinkComponent>().Initialize(10);
|
||||
}
|
||||
|
||||
public override void SendInitialState(BSONObject bsonObj, INetObjectViewer viewer)
|
||||
{
|
||||
base.SendInitialState(bsonObj, viewer);
|
||||
bsonObj["noFadeIn"] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
44
Objects/StorageChestObject.cs
Normal file
44
Objects/StorageChestObject.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) Strange Loop Games. All rights reserved.
|
||||
// See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Eco.Mods.TechTree
|
||||
{
|
||||
using Eco.Gameplay.Components;
|
||||
using Eco.Gameplay.Items;
|
||||
using Eco.Gameplay.Objects;
|
||||
using Eco.Shared.Serialization;
|
||||
using Eco.Gameplay.Components.Auth;
|
||||
|
||||
public partial class StorageChestObject : WorldObject
|
||||
{
|
||||
protected override void PostInitialize()
|
||||
{
|
||||
base.PostInitialize();
|
||||
this.GetComponent<PropertyAuthComponent>().Initialize(AuthModeType.Inherited);
|
||||
this.GetComponent<LinkComponent>().Initialize(10);
|
||||
this.GetComponent<MinimapComponent>().Initialize("Storage");
|
||||
}
|
||||
}
|
||||
|
||||
[Serialized]
|
||||
[RequireComponent(typeof(PropertyAuthComponent))]
|
||||
[RequireComponent(typeof(PublicStorageComponent))]
|
||||
[RequireComponent(typeof(LinkComponent))]
|
||||
[RequireComponent(typeof(MinimapComponent))]
|
||||
public class BigStorageChestObject : WorldObject
|
||||
{
|
||||
public override string FriendlyName { get { return "Big Storage Chest"; } }
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
var storage = this.GetComponent<PublicStorageComponent>();
|
||||
storage.Initialize(32, 8000000);
|
||||
storage.Storage.AddRestriction(new NotCarriedRestriction()); // can't store block or large items
|
||||
this.GetComponent<PropertyAuthComponent>().Initialize(AuthModeType.Inherited);
|
||||
this.GetComponent<LinkComponent>().Initialize(10);
|
||||
this.GetComponent<MinimapComponent>().Initialize("Storage");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user