Fix some docs, fix item use on server, update project settings

This commit is contained in:
excitedneon 2017-05-16 05:34:43 +03:00
parent f231252275
commit 427071c1d3
3 changed files with 17 additions and 3 deletions

View File

@ -6,6 +6,9 @@ namespace Cyber.Items {
/// An item, containing itemmy information.
/// </summary>
public class Item {
/// <summary>
/// Delegate for actions that items can do.
/// </summary>
public delegate void ItemAction(Character host);
/// <summary>
@ -52,6 +55,7 @@ namespace Cyber.Items {
/// <param name="weight">The Weight of the item.</param>
/// <param name="slot">The equip slot of the item.</param>
/// <param name="description">The description of the item.</param>
/// <param name="action">The action which is ran when the item is used.</param>
public Item(int id, int modelId, string name, float weight, EquipSlot slot, string description, ItemAction action = null) {
ID = id;
ModelID = modelId;

View File

@ -246,7 +246,8 @@ namespace Cyber.Networking.Serverside {
InventoryActionPkt InventoryActionPkt = new InventoryActionPkt();
InventoryActionPkt.Deserialize(msg.reader);
Inventory CurrInventory = Players[msg.conn.connectionId].Character.GetComponent<Inventory>();
Character Character = Players[msg.conn.connectionId].Character;
Inventory CurrInventory = Character.GetComponent<Inventory>();
InventoryActionPkt.SyncBaseID = CurrInventory.ID;
switch (InventoryActionPkt.Action) {
@ -258,6 +259,15 @@ namespace Cyber.Networking.Serverside {
EquipSlot Slot = (EquipSlot) InventoryActionPkt.RelatedInt;
CurrInventory.Equipped.ClearSlot(Slot);
break;
case InventoryAction.Use:
EquipSlot UseSlot = (EquipSlot) InventoryActionPkt.RelatedInt;
Item UseItem = CurrInventory.Equipped.GetItem(UseSlot);
if (UseItem != null && UseItem.Action != null && Character != null) {
// Item exists, it has an action, and the character
// isn't controlled by the client (no double-actions).
UseItem.Action(Character);
}
break;
}
SendToAll(PktType.InventoryAction, InventoryActionPkt);

View File

@ -10,7 +10,7 @@ PlayerSettings:
targetDevice: 2
useOnDemandResources: 0
accelerometerFrequency: 60
companyName: DefaultCompany
companyName: Saltosion
productName: Cyber
defaultCursor: {fileID: 0}
cursorHotspot: {x: 0, y: 0}
@ -64,7 +64,7 @@ PlayerSettings:
useOSAutorotation: 1
use32BitDisplayBuffer: 1
disableDepthAndStencilBuffers: 0
defaultIsFullScreen: 1
defaultIsFullScreen: 0
defaultIsNativeResolution: 1
runInBackground: 1
captureSingleScreen: 0