protected override void Init(MyObjectBuilder_DefinitionBase def) { base.Init(def); var ob = (MyObjectBuilder_EquiStateAnimVarsDefinition)def; foreach (var state in ob.States) { foreach (var when in state.When) { var stateKey = MyStringHash.GetOrCompute(when); Dictionary <MyStringId, SetInstruction> instructions; if (!_states.TryGetValue(stateKey, out instructions)) { _states.Add(stateKey, instructions = new Dictionary <MyStringId, SetInstruction>()); } foreach (var instruction in state.Instructions) { var varKey = MyStringId.GetOrCompute(instruction.Key); float valOutput; if (!string.IsNullOrWhiteSpace(instruction.Value) && float.TryParse(instruction.Value, out valOutput)) { instructions[varKey] = new SetInstruction(valOutput); } else if (instruction.Transform.HasValue) { var mat = instruction.Transform.Value.GetMatrix(); instructions[varKey] = new SetInstruction(new MyTransformD(in mat)); } else { MyDefinitionErrors.Add(Package, $"State {when} instruction {varKey} has no value", LogSeverity.Warning); } } } } }
private bool ExecuteInstruction(SetInstruction instruction) { registers[instruction.RegisterAddress] = instruction.Value; return(true); }