• R/O
  • HTTP
  • SSH
  • HTTPS

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

First Machine Age's Mods (Combined repo.)


File Info

Rev. 3195994595d48d697d116e78f1e42b17169a3214
크기 1,162 bytes
Time 2019-11-18 08:28:10
Author melchior
Log Message

W.I.P. #8; Nearly there

Content

using System;

using Vintagestory.API.Client;
using Vintagestory.API.Common;
using Vintagestory.API.Config;
using Vintagestory.GameContent;

namespace FirstMachineAge
{
	public class ItemKeylock : GenericLock
	{


		public override void OnHeldInteractStart(ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, bool firstEvent, ref EnumHandHandling handling)
		{
			
		if (byEntity.World.Side.IsClient( )) {
		ClientAPI = (byEntity.World.Api as ICoreClientAPI);
		}

		if (blockSel != null && byEntity.World.BlockAccessor.GetBlock(blockSel.Position).HasBehavior<BlockBehaviorComplexLockable>( )) {
		IPlayer player = (byEntity as EntityPlayer).Player;


		if (AccessControlsMod.LockState(blockSel.Position, player) != LockStatus.None)//already has a lock...
		{//TODO: Add Lock owner text
		ClientAPI?.TriggerIngameError(this, "cannotlock", Lang.Get("ingameerror-cannotlock"));
		}
		else {

		AccessControlsMod.ApplyLock(blockSel, player, slot);

		ClientAPI?.ShowChatMessage(Lang.Get("lockapplied"));
		slot.TakeOut(1);
		slot.MarkDirty( );
		}

		handling = EnumHandHandling.PreventDefault;
		return;
		}
					
		}
	}
}