public void parseBytes(byte[] arr, bool withType) { byte[] rawbytes = arr; if (withType) { this.type = this.configTypeFromBytes(arr); rawbytes = this.byteWithoutTypeByteFlag(arr); } if (this.type != ConfigType.None) { if (this.type == ConfigType.Fishing) { this.fishingConfig = this.fishingConfigFromBytes(rawbytes); } else if (this.type == ConfigType.Combat) { this.combatConfig = this.combatConfigFromBytes(rawbytes); } else if (this.type == ConfigType.Gathering) { this.gatheringConfig = this.gatheringConfigFromBytes(rawbytes); } } }
public GatheringConfig gatheringConfigFromBytes(byte[] arr) { GatheringConfig str = new GatheringConfig(); int size = Marshal.SizeOf(str); IntPtr ptr = Marshal.AllocHGlobal(size); Marshal.Copy(arr, 0, ptr, size); str = (GatheringConfig)Marshal.PtrToStructure(ptr, str.GetType()); Marshal.FreeHGlobal(ptr); return(str); }
public static GatheringConfig defaultGatheringConfig() { GatheringConfig defaultGathering = new GatheringConfig(); defaultGathering.matureTree = 0; defaultGathering.lushVegetationPatch = 0; defaultGathering.mineralDeposit = 0; defaultGathering.rockyOutcrop = 0; GeneralKeys defaultGeneral = new GeneralKeys(); defaultGeneral.forward = UseableKeys.W; defaultGeneral.backward = UseableKeys.S; defaultGeneral.rotateLeft = UseableKeys.A; defaultGeneral.rotateRight = UseableKeys.D; defaultGeneral.action = UseableKeys.Num0; defaultGathering.movement = defaultGeneral; return(defaultGathering); }