public void Init(ArkArchive archive) { IProperty property = PropertyRegistry.ReadBinary(archive); while (property != null) { Properties.Add(property); property = PropertyRegistry.ReadBinary(archive); } }
public StructPropertyList(ArkArchive archive, ArkName structType) : this(structType) { Properties = new Dictionary <ArkName, IProperty>(); var property = PropertyRegistry.readProperty(archive); while (property != null) { Properties.Add(ArkName.Create(property.Name.Token, property.Index), property); property = PropertyRegistry.readProperty(archive); } }
protected ShellApplication() { output = new ConsoleOutputDevice(System.Console.Out, true); message = new ConsoleOutputDevice(System.Console.Error, false); input = new ConsoleInputDevice(); dispatcher = new CommandDispatcher(this); if (this is ISettingsHandler) settings = new ApplicationSettings(this); if (this is IPropertyHandler) properties = new PropertyRegistry(this as IPropertyHandler); if (this is IPluginHandler) plugins = new ApplicationPlugins(this); interruptHandler = new ApplicationInterruptionHandler(this); }
public StructPropertyList(ArkArchive archive, ArkName structType, ArkNameTree exclusivePropertyNameTree = null) : this(structType) { Properties = new Dictionary <ArkName, IProperty>(); var property = PropertyRegistry.readProperty(archive, exclusivePropertyNameTree); while (property != null) { if (property != ExcludedProperty.Instance) { Properties.Add(ArkName.Create(property.Name.Token, property.Index), property); } property = PropertyRegistry.readProperty(archive, exclusivePropertyNameTree); } }
public void ReadJson(JToken node, ReadingOptions options) { className = node.Value <string>("className"); Properties.Clear(); JArray propertiesNode = node.Value <JArray>("properties"); if (propertiesNode != null) { foreach (JToken propertyNode in propertiesNode) { Properties.Add(PropertyRegistry.ReadJson((JObject)propertyNode)); } } }
public void ReadBinary(ArkArchive archive, ReadingOptions options) { className = archive.ReadString(); Properties.Clear(); try { IProperty property = PropertyRegistry.ReadBinary(archive); while (property != null) { Properties.Add(property); property = PropertyRegistry.ReadBinary(archive); } } catch (UnreadablePropertyException upe) { Debug.WriteLine(upe.Message); Debug.WriteLine(upe.StackTrace); } // TODO: verify 0 int at end }
public override CommandResultCode Execute(IExecutionContext context, CommandArguments args) { PropertyRegistry properties = Properties; if (properties == null) { Application.Error.WriteLine("the current context does not support properties."); return(CommandResultCode.ExecutionFailed); } if (args.MoveNext()) { string name = args.Current; PropertyHolder holder = properties.GetProperty(name); if (holder == null) { return(CommandResultCode.ExecutionFailed); } PrintDescription(name, holder, Application.Error); return(CommandResultCode.Success); } ProperiesColumns[0].ResetWidth(); ProperiesColumns[1].ResetWidth(); TableRenderer table = new TableRenderer(ProperiesColumns, Application.Out); foreach (KeyValuePair <string, PropertyHolder> entry in properties) { ColumnValue[] row = new ColumnValue[3]; PropertyHolder holder = entry.Value; row[0] = new ColumnValue(entry.Key); row[1] = new ColumnValue(holder.Value); row[2] = new ColumnValue(holder.ShortDescription); table.AddRow(row); } table.CloseTable(); return(CommandResultCode.Success); }
public override CommandResultCode Execute(IExecutionContext context, CommandArguments args) { if (args.Count != 1) { return(CommandResultCode.SyntaxError); } PropertyRegistry properties = Properties; if (properties == null) { Application.Error.WriteLine("the current context does not support properties."); return(CommandResultCode.ExecutionFailed); } if (!args.MoveNext()) { return(CommandResultCode.SyntaxError); } String name = args.Current; PropertyHolder holder = properties.GetProperty(name); if (holder == null) { return(CommandResultCode.ExecutionFailed); } string defaultValue = holder.DefaultValue; try { properties.SetProperty(name, defaultValue); } catch (Exception) { Application.Error.WriteLine("setting to default '" + defaultValue + "' failed."); return(CommandResultCode.ExecutionFailed); } return(CommandResultCode.Success); }
public void loadProperties(ArkArchive archive, GameObject next, long propertiesBlockOffset, int?nextGameObjectPropertiesOffset = null) { var offset = propertiesBlockOffset + _propertiesOffset; var nextOffset = nextGameObjectPropertiesOffset != null ? propertiesBlockOffset + nextGameObjectPropertiesOffset.Value : (next != null) ? propertiesBlockOffset + next._propertiesOffset : archive.Size - 1; archive.Position = offset; properties.Clear(); try { var property = PropertyRegistry.readProperty(archive, null); while (property != null) { if (property != ExcludedProperty.Instance) { properties.Add(_arkNameCache.Create(property.Name.Token, property.Index), property); } property = PropertyRegistry.readProperty(archive, archive.ExclusivePropertyNameTree); } } catch (UnreadablePropertyException) { // Stop reading and ignore possible extra data for now, needs a new field in ExtraDataHandler return; } finally { //these are in order of most common to least common to keep lookups at a minimum if (Properties.ContainsKey(_ownerName) || Properties.ContainsKey(_bHasResetDecayTime) || ClassName.Name == "CherufeNest_C") { if (ClassName.Token.StartsWith("DeathItemCache_")) { _isFlags |= GameObjectIs.IsDeathItemCache; goto SkipRest; } _isFlags |= GameObjectIs.IsStructure; goto SkipRest; } if (Properties.ContainsKey(_dinoId1)) { _isFlags |= GameObjectIs.IsCreature; } int tamingTeamID = 0; int targetingTeamId = 0; if (IsCreature) { if (Properties.ContainsKey(_tamingTeamID)) { PropertyInt32 tamingTeam = (PropertyInt32)Properties[_tamingTeamID]; tamingTeamID = tamingTeam.Value.GetValueOrDefault(0); } if (Properties.ContainsKey(_targetTeamID)) { PropertyInt32 targetingTeam = (PropertyInt32)Properties[_targetTeamID]; targetingTeamId = targetingTeam.Value.GetValueOrDefault(0); } if (targetingTeamId > 1000000000) { if ((tamingTeamID > 0 && tamingTeamID < 1000000000) & !Properties.ContainsKey(_imprinterName)) { } else { _isFlags |= GameObjectIs.IsTamedCreature; } } } if (IsCreature && !IsTamedCreature) { _isFlags |= GameObjectIs.IsWildCreature; } if (IsTamedCreature && (ClassName.Equals(_raft_bp_c) || ClassName.Equals(_motorraft_bp_c))) { _isFlags |= GameObjectIs.IsRaftCreature; } if (Properties.ContainsKey(_currentStatusValues)) { _isFlags |= GameObjectIs.IsStatusComponent; } if (IsStatusComponent && ClassName.Token.StartsWith("DinoCharacterStatusComponent_")) { _isFlags |= GameObjectIs.IsDinoStatusComponent; } if (IsStatusComponent && !IsDinoStatusComponent && ClassName.Token.StartsWith("PlayerCharacterStatusComponent_")) { _isFlags |= GameObjectIs.IsPlayerCharacterStatusComponent; } if (ClassName.Token.StartsWith("DroppedItemGeneric_") & !ClassName.Name.Contains("NoPhysics")) { if (Properties.ContainsKey(_droppedByPlayerId)) { PropertyInt64 selectedPlayerId = (PropertyInt64)Properties[_droppedByPlayerId]; if (selectedPlayerId.Value != 0) { _isFlags |= GameObjectIs.IsDroppedItem; } } } if (IsItem) { goto SkipRest; } if (IsCreature) { goto SkipRest; } if (IsStatusComponent) { goto SkipRest; } if (Properties.ContainsKey(_bInitializedMe)) { _isFlags |= GameObjectIs.IsInventory; } if (IsInventory && ClassName.Token.StartsWith("PrimalInventoryBP_")) { _isFlags |= GameObjectIs.IsStructureInventory; } if (IsInventory && !IsStructureInventory && ClassName.Token.StartsWith("DinoTamedInventoryComponent_")) { _isFlags |= GameObjectIs.IsTamedCreatureInventory; } if (IsInventory && !(IsStructureInventory || IsTamedCreatureInventory) && ClassName.Token.StartsWith("PrimalInventoryComponent")) { _isFlags |= GameObjectIs.IsPlayerCharacterInventory; } if (IsInventory && !(IsStructureInventory || IsTamedCreatureInventory || IsPlayerCharacterInventory) && ClassName.Token.StartsWith("DinoWildInventoryComponent_")) { _isFlags |= GameObjectIs.IsWildCreatureInventory; } if (IsInventory) { goto SkipRest; } if (ClassName.Equals(_structurePaintingComponent)) { _isFlags |= GameObjectIs.IsStructurePaintingComponent; goto SkipRest; } if (ClassName.Equals(_droppedItem)) { _isFlags |= GameObjectIs.IsDroppedItem; goto SkipRest; } if (ClassName.Equals(_male) || ClassName.Equals(_female)) { _isFlags |= GameObjectIs.IsPlayerCharacter; goto SkipRest; } _isFlags |= GameObjectIs.IsSomethingElse; //IsStructure = (Properties.ContainsKey(_ownerName) || Properties.ContainsKey(_bHasResetDecayTime)); //if (IsStructure) goto SkipRest; //IsCreature = Properties.ContainsKey(_dinoId1); //IsTamedCreature = IsCreature && (Properties.ContainsKey(_tamerString) || Properties.ContainsKey(_tamingTeamID)); //IsWildCreature = IsCreature && !IsTamedCreature; //IsRaftCreature = IsTamedCreature && ClassName.Equals(_raft_bp_c); //if (IsCreature) goto SkipRest; //IsStatusComponent = Properties.ContainsKey(_currentStatusValues); //IsDinoStatusComponent = IsStatusComponent && ClassName.Token.StartsWith("DinoCharacterStatusComponent_"); //IsPlayerCharacterStatusComponent = IsStatusComponent && !IsDinoStatusComponent && ClassName.Token.StartsWith("PlayerCharacterStatusComponent_"); //if (IsStatusComponent) goto SkipRest; //IsInventory = Properties.ContainsKey(_bInitializedMe); //IsStructureInventory = IsInventory && ClassName.Token.StartsWith("PrimalInventoryBP_"); //IsTamedCreatureInventory = IsInventory && !IsStructureInventory && ClassName.Token.StartsWith("DinoTamedInventoryComponent_"); //IsPlayerCharacterInventory = IsInventory && !(IsStructureInventory || IsTamedCreatureInventory) && ClassName.Token.StartsWith("PrimalInventoryComponent"); //IsWildCreatureInventory = IsInventory && !(IsStructureInventory || IsTamedCreatureInventory || IsPlayerCharacterInventory) && ClassName.Token.StartsWith("DinoWildInventoryComponent_"); //if (IsInventory) goto SkipRest; //IsStructurePaintingComponent = ClassName.Equals(_structurePaintingComponent); //if (IsStructurePaintingComponent) goto SkipRest; //IsDroppedItem = ClassName.Equals(_droppedItem); //if (IsDroppedItem) goto SkipRest; //IsPlayerCharacter = ClassName.Equals(_male) || ClassName.Equals(_female); //if (IsPlayerCharacter) goto SkipRest; //IsSomethingElse = true; SkipRest :; } var distance = nextOffset - archive.Position; if (distance > 0) { ExtraData = ExtraDataRegistry.getExtraData(this, archive, distance); } else { ExtraData = null; } }
public override IEnumerator <string> Complete(CommandDispatcher dispatcher, string partialCommand, string lastWord) { PropertyRegistry properties = Properties; return(properties == null ? null : properties.Complete(Name, partialCommand, lastWord)); }
public void Init(JArray node) { Properties = node.Select(n => PropertyRegistry.ReadJson((JObject)n)).ToList(); }
public override CommandResultCode Execute(IExecutionContext context, CommandArguments args) { if (!args.MoveNext()) { return(CommandResultCode.SyntaxError); } string varname = args.Current; string[] newArgs = new string[args.Count - 1]; while (args.MoveNext()) { newArgs[args.CurrentIndex - 1] = args.Current; } string param = String.Join(" ", newArgs); int pos = 0; int paramLength = param.Length; // skip whitespace after 'set' while (pos < paramLength && Char.IsWhiteSpace(param[pos])) { ++pos; } // skip non-whitespace after 'set ': variable name while (pos < paramLength && !Char.IsWhiteSpace(param[pos])) { ++pos; } // skip whitespace before vlue.. while (pos < paramLength && Char.IsWhiteSpace(param[pos])) { ++pos; } String value = param.Substring(pos); if (value.StartsWith("\"") && value.EndsWith("\"")) { value = value.Substring(1, value.Length - 2); } else if (value.StartsWith("\'") && value.EndsWith("\'")) { value = value.Substring(1, value.Length - 2); } try { PropertyRegistry properties = Properties; if (properties == null) { throw new Exception("The current context doesn't support properties."); } properties.SetProperty(varname, value); } catch (Exception e) { Application.Error.WriteLine(e.Message); return(CommandResultCode.ExecutionFailed); } return(CommandResultCode.Success); }
public void loadProperties(ArkArchive archive, GameObject next, long propertiesBlockOffset, int?nextGameObjectPropertiesOffset = null) { var offset = propertiesBlockOffset + _propertiesOffset; var nextOffset = nextGameObjectPropertiesOffset != null ? propertiesBlockOffset + nextGameObjectPropertiesOffset.Value : (next != null) ? propertiesBlockOffset + next._propertiesOffset : archive.Size - 1; archive.Position = offset; properties.Clear(); try { var property = PropertyRegistry.readProperty(archive); while (property != null) { properties.Add(_arkNameCache.Create(property.Name.Token, property.Index), property); property = PropertyRegistry.readProperty(archive); } } catch (UnreadablePropertyException) { // Stop reading and ignore possible extra data for now, needs a new field in ExtraDataHandler return; } finally { //these are in order of most common to least common to keep lookups at a minimum if (IsItem) { goto SkipRest; } IsStructure = (Properties.ContainsKey(_ownerName) || Properties.ContainsKey(_bHasResetDecayTime)); if (IsStructure) { goto SkipRest; } IsCreature = Properties.ContainsKey(_dinoId1); IsTamedCreature = IsCreature && (Properties.ContainsKey(_tamerString) || Properties.ContainsKey(_tamingTeamID)); IsWildCreature = IsCreature && !IsTamedCreature; IsRaftCreature = IsTamedCreature && ClassName.Equals(_raft_bp_c); if (IsCreature) { goto SkipRest; } IsStatusComponent = Properties.ContainsKey(_currentStatusValues); IsDinoStatusComponent = IsStatusComponent && ClassName.Token.StartsWith("DinoCharacterStatusComponent_"); IsPlayerCharacterStatusComponent = IsStatusComponent && !IsDinoStatusComponent && ClassName.Token.StartsWith("PlayerCharacterStatusComponent_"); if (IsStatusComponent) { goto SkipRest; } IsInventory = Properties.ContainsKey(_bInitializedMe); IsStructureInventory = IsInventory && ClassName.Token.StartsWith("PrimalInventoryBP_"); IsTamedCreatureInventory = IsInventory && !IsStructureInventory && ClassName.Token.StartsWith("DinoTamedInventoryComponent_"); IsPlayerCharacterInventory = IsInventory && !(IsStructureInventory || IsTamedCreatureInventory) && ClassName.Token.StartsWith("PrimalInventoryComponent"); IsWildCreatureInventory = IsInventory && !(IsStructureInventory || IsTamedCreatureInventory || IsPlayerCharacterInventory) && ClassName.Token.StartsWith("DinoWildInventoryComponent_"); if (IsInventory) { goto SkipRest; } IsStructurePaintingComponent = ClassName.Equals(_structurePaintingComponent); if (IsStructurePaintingComponent) { goto SkipRest; } IsDroppedItem = ClassName.Equals(_droppedItem); if (IsDroppedItem) { goto SkipRest; } IsPlayerCharacter = ClassName.Equals(_male) || ClassName.Equals(_female); if (IsPlayerCharacter) { goto SkipRest; } IsSomethingElse = true; SkipRest :; } var distance = nextOffset - archive.Position; if (distance > 0) { ExtraData = ExtraDataRegistry.getExtraData(this, archive, distance); } else { ExtraData = null; } }