コード例 #1
0
        /// <summary>
        /// Checks both internal and external constraints and, if successful,
        /// changes the state of the variable in accordance with requests (including data writing)
        /// </summary>
        internal override void Precommit()
        {
            if (!HasChanges)
            {
                return;
            }

            if (commitStage > CommitStage.Precommitting)
            {
                return;
            }

            try
            {
                /* Checking internal constraints */
                DoCheckConstraints();

                commitStage = CommitStage.Precommitting;

                /* Checking external constraints */
                if (!FireEventVariableCommitting(changes))
                {
                    throw new Exception("Commission is cancelled.");
                }

                /* To avoid duplicate execution of the following code,
                 * because it might be executed in Precommit of dependand DataSet as
                 * a part of the VariableCommitting event handling */
                if (commitStage > CommitStage.Precommitting)
                {
                    return;
                }

                /* Changing state of the variable */
                if (changes.DataPieces != null && changes.DataPieces.Count > 0)
                {
                    BeginWriteTransaction();
                    writeTransactionOpened = true;

                    while (changes.DataPieces.Count > 0)
                    {
                        DataPiece piece = changes.DataPieces[0];
                        WriteData(piece.Origin, piece.Data);

                        changes.DataPieces.RemoveAt(0);
                    }
                }
            }
            catch
            {
                /* If operation failed rolling back to "changed" state.
                 * Now it is possible either to Rollback to previous committed state or
                 * make further changes to fix errors.*/
                commitStage = CommitStage.Changed;
                throw;
            }

            /* Success: this variable is ready for commission */
            commitStage = CommitStage.Precommitted;
        }
コード例 #2
0
 /// <summary>
 /// 添加键
 /// </summary>
 public void AddKey(string k)
 {
     mCurrPiece = new DataPiece()
     {
         Key = k, Value = string.Empty
     };
 }
コード例 #3
0
        public override void ReadData(BinaryReader reader)
        {
            bool isOld  = ModdedSaveData.LATEST_READ_VERSION < 4;
            int  number = reader.ReadInt32();

            if (number >= 3)
            {
                isOld = false;
            }

            if (number >= 3)
            {
                number -= 3;
            }
            idType = (IdentifierType)number;
            if (!isOld)
            {
                Version = reader.ReadInt32();
            }
            longIdentifier   = reader.ReadInt64();
            stringIdentifier = isOld ? "" : reader.ReadString();
            dataPiece        = DataPiece.Deserialize(reader) as CompoundDataPiece;
            if (dataPiece == null)
            {
                throw new Exception("Invalid top level datapiece!");
            }
        }
コード例 #4
0
ファイル: SavedData.cs プロジェクト: mtegene/Lumilo_UI
    public static DataPieceSer changeDataPiecetoDataPieceSer(DataPiece d)
    {
        DataPieceSer ans = new DataPieceSer();

        ans.datatype  = d.datatype;
        ans.id        = d.id;
        ans.firstName = d.firstName;
        ans.lastName  = d.lastName;

        if (d.classes == null)
        {
            ans.classes = null;
        }
        else
        {
            ans.classes = d.classes.ToArray();
        }

        ans.class_summary = d.class_summary;
        if (d.students == null)
        {
            ans.students = null;
        }
        else
        {
            ans.students = d.students.ToArray();
        }

        ans.infoBeingDisplayed = d.infoBeingDisplayed;
        ans.detector_saver     = new DetectorSerializer();
        ans.detector_saver.beforeSter(d.detectors);
        return(ans);
    }
コード例 #5
0
 protected override void CommitWrite(DataChanges proposedChanges)
 {
     if (proposedChanges != null && proposedChanges.HasData)
     {
         if (getRecentDataCalled)
         {
             array = copyArray;
         }
         else
         {
             int n = proposedChanges.Data.Count;
             if (copyArray != null)
             {
                 if (array.Data != null)
                 {
                     copyArray.PutData(null, array.Data);
                 }
                 array = copyArray;
             }
             for (int i = 0; i < n; i++)
             {
                 DataPiece piece = proposedChanges.Data[i];
                 array.PutData(piece.Origin, piece.Data);
             }
         }
     }
     recentChanges       = null;
     getRecentDataCalled = false;
 }
コード例 #6
0
ファイル: SavedData.cs プロジェクト: mtegene/Lumilo_UI
    public DetectorSerializer detector_saver; //Use this to serialze the dectors [different procedure bc it's a dictionary]

    public static DataPiece changeDataPieceSertoDataPiece(DataPieceSer d)
    {
        DataPiece ans = new DataPiece();

        ans.datatype  = d.datatype;
        ans.id        = d.id;
        ans.firstName = d.firstName;
        ans.lastName  = d.lastName;

        if (d.classes == null)
        {
            ans.classes = new List <string>();
        }
        else
        {
            ans.classes = new List <string>(d.classes);
        }

        ans.class_summary = d.class_summary;

        if (d.students == null)
        {
            ans.students = new List <string>();
        }
        else
        {
            ans.students = new List <string>(d.students);
        }

        ans.infoBeingDisplayed = d.infoBeingDisplayed;
        ans.detectors          = d.detector_saver.afterSter();
        return(ans);
    }
コード例 #7
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "PlayerBullet")
        {
            lives--;
        }

        if (lives == 0)
        {
            Instantiate(Resources.Load("CentipedeExplosion"), transform.position, Quaternion.identity);
            GameManager.instance.AudioManager.PlaySFX("Explosion");
            Camera.main.GetComponent <Shake>().Shaking(0.2f);
            Destroy(this.gameObject);
        }

        if (col.gameObject.tag == "DataPiece")
        {
            DataPiece dp = col.gameObject.GetComponent <DataPiece> ();
            if (dp != null)
            {
                if (dp.landed)
                {
                    GameManager.instance.score            += score;
                    GameManager.instance.corruption_level += corruptionLevel;
                    Destroy(gameObject);
                }
            }
        }
    }
コード例 #8
0
        private DataPiece GenerateDataPiece(Random rnd, Guid trackId, DateTime timestamp, double lat, double lng)
        {
            var x = rnd.NextDouble();
            var y = rnd.NextDouble();
            var z = rnd.NextDouble();

            var ret = new DataPiece {
                TrackId        = trackId,
                StartTimestamp = timestamp,
                EndTimestamp   = timestamp.Add(PieceInterval),
                PpeX           = x,
                PpeY           = y,
                PpeZ           = z,
                Ppe            = (x + y + z) / 3.0,
                Latitude       = lat,
                Longitude      = lng,
                Accuracy       = (int)(rnd.NextDouble() * 30),
                Bearing        = 0f,
                Speed          = 0,
                Anchorage      = Shared.AnchorageType.MobileBracket,
                Vehicle        = Shared.VehicleType.Car
            };

            return(ret);
        }
コード例 #9
0
 public void HandleData(DataPiece dataPiece)
 {
     Console.Clear();
     Console.WriteLine(dataPiece.IsRaceOn == 1 ? "Race is on." : "Race is off.");
     Console.WriteLine(String.Format("RPM: {0}", dataPiece.CurrentEngineRpm));
     Console.WriteLine(String.Format("Gear: {0}", dataPiece.Gear));
     Console.WriteLine(String.Format("Speed: {0}", dataPiece.Speed * 3.6f));
 }
コード例 #10
0
 public override void WriteData(BinaryWriter writer)
 {
     writer.Write((int)idType);
     writer.Write(Version);
     writer.Write(longIdentifier);
     writer.Write(stringIdentifier);
     DataPiece.Serialize(writer, dataPiece);
 }
コード例 #11
0
ファイル: SavedData.cs プロジェクト: mtegene/Lumilo_UI
 public bool get(string s, out DataPiece d)
 {
     if (central_dictionary == null)
     {
         d = null;
         return(false);
     }
     return(SavedData.data.central_dictionary.TryGetValue(s, out d));
 }
コード例 #12
0
ファイル: SavedData.cs プロジェクト: mtegene/Lumilo_UI
 public bool add(string s, DataPiece o)
 {
     if (central_dictionary == null)
     {
         central_dictionary = new Dictionary <string, DataPiece>();
     }
     SavedData.data.central_dictionary.Add(s, o);
     return(true);
 }
コード例 #13
0
 public void HandleData(DataPiece dataPiece)
 {
     if (dataHandler != null)
     {
         if (dataPiece.IsRaceOn == 1)
         {
             Dispatcher.Invoke(dataHandler, dataPiece);
         }
     }
 }
コード例 #14
0
ファイル: ExtendedDataTree.cs プロジェクト: Halocaster/SRML
 public void Read(BinaryReader reader)
 {
     idType     = (IdentifierType)reader.ReadInt32();
     identifier = reader.ReadInt64();
     dataPiece  = DataPiece.Deserialize(reader) as CompoundDataPiece;
     if (dataPiece == null)
     {
         throw new Exception("Invalid top level data piece!");
     }
 }
コード例 #15
0
        public void Write(BinaryWriter writer)
        {
            version = DATA_VERSION;
            var start = writer.BaseStream.Position;

            writer.Write(version);
            writer.Write(modid);
            var overwritePosition = writer.BaseStream.Position;

            writer.Write((long)0);
            if (!(SRModLoader.GetMod(modid) is SRMod mod))
            {
                throw new Exception($"Unrecognized mod id: {modid}");
            }
            var saveInfo = SaveRegistry.GetSaveInfo(mod);

            writer.Write(identifiableData.Count);
            foreach (var data in identifiableData)
            {
                data.Write(writer, saveInfo);
            }

            writer.Write(extendedData.Count);
            foreach (var data in extendedData)
            {
                data.Write(writer);
            }

            playerData.Write(writer);
            pediaData.Write(writer);

            BinaryUtils.WriteDictionary(writer, customAmmo, (x, y) => AmmoIdentifier.Write(y, x), (x, y) =>
            {
                x.Write(y.Count);
                foreach (var v in y)
                {
                    x.Write(v != null);
                    if (v != null)
                    {
                        v.Write(x.BaseStream);
                    }
                }
            });

            DataPiece.Serialize(writer, extendedWorldData);

            worldData.Write(writer);

            var cur = writer.BaseStream.Position;

            writer.BaseStream.Seek(overwritePosition, SeekOrigin.Begin);
            byteLength = cur - (start);
            writer.Write(byteLength);
            writer.BaseStream.Seek(cur, SeekOrigin.Begin);
        }
コード例 #16
0
    private static void removeInvisibleHandIndicatorIndicator(DataPiece si)
    {
        GameObject invisibleHandIndicator = GameObject.Find(si.id + "IH");

        if (invisibleHandIndicator == null)
        {
            Debug.LogError("Tryting to remove a handRaiseIndicator that does not exist");
        }

        Destroy(invisibleHandIndicator);
    }
コード例 #17
0
 /// <summary>
 /// Adds new data to the dataList - if it doesn't exist yet.
 /// </summary>
 /// <returns>false if data piece already exists</returns>
 public GameEventData Add(DataPiece newData)
 {
     try
     {
         dataList.Add(newData.id, newData);
         return this;
     }
     catch(System.ArgumentException)
     {
         Debug.LogWarning("Key " + newData.id + " already exists in EventData.");
         return this;
     }
 }
コード例 #18
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "PlayerBullet")
        {
            lives--;

            if (lives == 0)
            {
                if (CanDivide)
                {
                    subViruses.SetActive(true);
                    subViruses.transform.parent = null;
                }
                GameManager.instance.AudioManager.PlaySFX("SubdividedVirus");
                GameManager.instance.score += score;
                Destroy(this.gameObject);

                GameObject ps = null;
                if (corruptionLevel == 20)
                {
                    ps = Instantiate(Resources.Load("Large Divide"), transform.position, Quaternion.identity) as GameObject;
                    Camera.main.GetComponent <Shake>().Shaking(0.2f);
                }
                if (corruptionLevel == 4)
                {
                    ps = Instantiate(Resources.Load("Medium Divide"), transform.position, Quaternion.identity) as GameObject;
                    Camera.main.GetComponent <Shake>().Shaking(0.05f);
                }
                if (corruptionLevel == 1)
                {
                    ps = Instantiate(Resources.Load("Small Death"), transform.position, Quaternion.identity) as GameObject;
                }
            }
        }

        if (col.gameObject.tag == "DataPiece")
        {
            DataPiece dp = col.gameObject.GetComponent <DataPiece> ();
            if (dp != null)
            {
                if (dp.landed)
                {
                    GameManager.instance.corruption_level += corruptionLevel;
                    Destroy(gameObject);
                }
            }
        }
    }
コード例 #19
0
        /// <summary>
        /// Adds the data to the variable starting with specified origin indices.
        /// </summary>
        /// <param name="origin">Indices to start adding of data. Null means all zeros.</param>
        /// <param name="a">Data to add to the variable.</param>
        public override void PutData(int[] origin, Array a)
        {
            if (origin != null && origin.Length != Rank)
            {
                throw new ArgumentException("Origin contains incorrect number of dimensions.");
            }
            if (a.Rank != Rank)
            {
                throw new ArgumentException("Array has wrong rank.");
            }

            StartChanging();

            if (origin == null)
            {
                origin = new int[Rank];
            }

            // Updating shape
            DimensionList proposedDims = changes.Dimensions;

            if (proposedDims == null)
            {
                proposedDims       = dims.Clone();
                changes.Dimensions = proposedDims;
            }

            for (int i = 0; i < proposedDims.Count; i++)
            {
                int shape = origin[i] + a.GetLength(i);
                if (shape > proposedDims[i].Length)
                {
                    proposedDims[i] = new Dimension(proposedDims[i].Name, shape);
                }
            }

            // Adding new data piece to the change list
            DataPiece piece = new DataPiece();

            piece.Origin = origin;
            piece.Data   = a;

            changes.DataPieces.Add(piece);

            // Firing the event
            FireEventVariableChanged(VariableChangeAction.PutData);
        }
コード例 #20
0
        public void UpdateGraph(DataPiece data)
        {
            if (!drawing)
            {
                graphFigure            = new PathFigure();
                graphFigure.Segments   = new PathSegmentCollection();
                graphFigure.StartPoint = new Point(MapCanvas.ActualWidth - (double)data.PositionX - 450, MapCanvas.ActualHeight + (double)data.PositionZ + 30);

                drawing = true;
            }
            else
            {
                graphFigure.Segments.Add(new LineSegment(new Point(MapCanvas.ActualWidth - (double)data.PositionX - 450, MapCanvas.ActualHeight + (double)data.PositionZ + 30), true));
            }

            graphGeometry.Figures[0] = graphFigure;

            MapPath.Data = graphGeometry;
        }
コード例 #21
0
        public void UpdateSheet(DataPiece data)
        {
            if (data.LapNumber > currentLap)
            {
                //if (data.LapNumber + 1 > 0)
                //{
                currentLap       = (int)data.LapNumber;
                lapStartDistance = data.DistanceTraveled.Value;

                if (data.LapNumber >= 1)
                {
                    laps[laps.Count - 1].LapTime = TimeSpan.FromSeconds((double)data.LastLap);
                }

                laps.Add(new Lap());
                laps[laps.Count - 1].LapNo      = currentLap;
                laps[laps.Count - 1].InterTimes = new TimeSpan[6];

                interStep = 0;

                previousInterTime = data.CurrentRaceTime.Value;

                LapChart.Items.Refresh();
                //}

                return;
            }


            if (data.DistanceTraveled - lapStartDistance >= interDistances[interStep] && interStep < interDistances.Length - 1)
            {
                laps[laps.Count - 1].InterTimes[interStep] = TimeSpan.FromSeconds(data.CurrentRaceTime.Value - previousInterTime);

                interStep++;
                previousInterTime = data.CurrentRaceTime.Value;

                LapChart.Items.Refresh();

                return;
            }
        }
コード例 #22
0
    //Indicator Stuff
    public static GameObject createStudentIndicator(DataPiece si)
    {
        GameObject studentIndicator = Instantiate(normalStudentIndicatorStatic);

        //Set the name to unique id so that it's easy to find later in updateIndicator
        studentIndicator.name = si.id;

        //Sets position and scale
        studentIndicator.transform.localScale -= new Vector3(0.5f, 0.5f, 0.5f);
        studentIndicator.transform.position    = new Vector3((counter * 0.5f) - 3, 0, 7 - (counter * 0.6f));

        //Adds a WorldAnchor to the game object (student indicator)
        createWorldAnchor(studentIndicator, si.id);

        counter++;

        //If there is anything we wanna display on the sphere
        si.infoBeingDisplayed = "";

        return(studentIndicator);
    }
コード例 #23
0
        /// <summary>
        /// The method is called at the precommit stage of the variable.
        /// </summary>
        /// <remarks>
        /// <see cref="DataAccessVariable{DataType}"/> opens a write-transaction and actually updates the related storage with
        /// accumulated changes.
        /// </remarks>
        internal protected override void OnPrecommit(Variable.Changes proposedChanges)
        {
            /* Changing state of the variable */
            DataChanges dataChanges = proposedChanges as DataChanges;

            if (dataChanges != null && dataChanges.HasData)
            {
                // Writing data
                BeginWriteTransaction(dataChanges);
                writeTransactionOpened = true;

                if (dataChanges.Data != null)
                {
                    int n = dataChanges.Data.Count;
                    for (int i = 0; i < n; i++)
                    {
                        DataPiece piece = dataChanges.Data[i];
                        WriteData(piece.Origin, piece.Data);
                    }
                }
            }
        }
コード例 #24
0
        public void UpdateGraphs(DataPiece data)
        {
            if (data.LapNumber > currentLap)
            {
                xResolution = TRACK_LENGTH / 1500d;

                currentLap       = (int)data.LapNumber;
                lapStartDistance = data.DistanceTraveled.Value;
                distanceStep     = 0;

                graphs[0].UpdateGraph(0, (int)(data.Speed * 3.6f), true);
                graphs[1].UpdateGraph(0, (int)data.Accel, true);
                graphs[2].UpdateGraph(0, (int)data.Brake, true);
                graphs[3].UpdateGraph(0, (int)data.Steer, true);
                graphs[4].UpdateGraph(0, (int)data.CurrentEngineRpm, true);
                graphs[5].UpdateGraph(0, (int)data.Power / 1000, true);
                graphs[6].UpdateGraph(0, (int)data.Torque, true);

                distanceStep++;
                return;
            }


            if (data.DistanceTraveled >= lapStartDistance + (distanceStep * xResolution))
            {
                graphs[0].UpdateGraph(distanceStep, (int)(data.Speed * 3.6f));
                graphs[1].UpdateGraph(distanceStep, (int)data.Accel);
                graphs[2].UpdateGraph(distanceStep, (int)data.Brake);
                graphs[3].UpdateGraph(distanceStep, (int)data.Steer);
                graphs[4].UpdateGraph(distanceStep, (int)data.CurrentEngineRpm);
                graphs[5].UpdateGraph(distanceStep, (int)data.Power / 1000);
                graphs[6].UpdateGraph(distanceStep, (int)data.Torque);

                distanceStep++;

                return;
            }
        }
コード例 #25
0
ファイル: Centipede.cs プロジェクト: Esmouc/LudumDareGame
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "DataPiece")
        {
            DataPiece dp = col.gameObject.GetComponent <DataPiece> ();
            if (dp != null)
            {
                if (dp.landed)
                {
                    GameManager.instance.corruption_level += corruptionLevel;
                }
            }
        }

        if (col.gameObject.tag == "PlayerBullet")
        {
            lives--;
            if (lives == 0)
            {
                GameManager.instance.score += score;
                for (int i = 0; i < 10; i++)
                {
                    GameObject go = (GameObject)Instantiate(Bullet, transform.position, Quaternion.identity);
                    GameManager.instance.AudioManager.PlaySFX("EnemyShot");
                    go.transform.Rotate(new Vector3(0, 0, 36) * i);
                    go.GetComponent <Bullet> ().direction = go.transform.up;
                    go.transform.position += go.transform.up / 3;
                    go.GetComponent <Bullet> ().UpdateVelocity();
                }
                Instantiate(Resources.Load("CentipedeExplosion"), transform.position, Quaternion.identity);
                GameManager.instance.AudioManager.PlaySFX("Explosion");
                Camera.main.GetComponent <Shake>().Shaking(0.3f);
                Destroy(gameObject);
            }
        }
    }
コード例 #26
0
 /// <summary>
 /// Gets the recent data from the variable.
 /// </summary>
 /// <returns></returns>
 /// <remarks>
 /// The method is to be called from the DataSet.OnPrecommit method.
 /// </remarks>
 Array IInternalMemoryVariable.GetRecentData()
 {
     if (recentChanges == null)
     {
         var data = array.Data;
         if (data == null)
         {
             return(Array.CreateInstance(TypeOfData, new int[Rank]));
         }
         return(data);
     }
     else
     {
         if (getRecentDataCalled)
         {
             return(copyArray.Data);
         }
         int n = Rank;
         if (copyArray == null)                 // no enlarge
         {
             copyArray      = new ArrayWrapper(n, TypeOfData);
             copyArray.Data = (Array)array.Data.Clone();
         }
         else if (array.Data != null)
         {
             copyArray.PutData(null, array.Data);
         }
         for (int i = 0; i < recentChanges.Data.Count; i++)
         {
             DataPiece piece = recentChanges.Data[i];
             copyArray.PutData(piece.Origin, piece.Data);
         }
         getRecentDataCalled = true;
         return(copyArray.Data);
     }
 }
コード例 #27
0
        public void Read(BinaryReader reader)
        {
            data.Clear();
            var count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                bool shouldbenull = reader.ReadBoolean();
                if (shouldbenull)
                {
                    data.Add(null);
                }
                else
                {
                    var piece = DataPiece.Deserialize(reader) as CompoundDataPiece;
                    ExtendedData.CullMissingModsFromData(piece);
                    if (piece.DataList.Count == 0)
                    {
                        piece = null;
                    }
                    data.Add(piece);
                }
            }
        }
コード例 #28
0
ファイル: ExtendedDataTree.cs プロジェクト: Halocaster/SRML
 public void Write(BinaryWriter writer)
 {
     writer.Write((int)idType);
     writer.Write(identifier);
     DataPiece.Serialize(writer, dataPiece);
 }
コード例 #29
0
    //need to deal with the hadn indicator
    public static void updateStudentIndicator(string changedDetector, DataPiece si)
    {
        //if changedDetector is being displayed, modify the indicator
        //othersiwse do nothing

        //get the game indicator we're gonna be dealing with
        GameObject indicator = GameObject.Find(si.id);

        if (indicator == null)
        {
            indicator = createStudentIndicator(si);
        }

        //deal with old invalid detectors cuz code will crash
        if (changedDetector.Equals("current_attempt_count") || changedDetector.Equals("help_model_try_if_low"))
        {
            return;
        }

        //get the value of the detector
        string detector_value;

        si.detectors.TryGetValue(changedDetector, out detector_value);
        if (detector_value == null || detector_value == "")
        {
            Debug.LogError("No valid value assoicated with the detector");
        }

        //determine if detector is on
        bool detector_on = detector_value.StartsWith("1");

        //NEED TO CHANGE THIS. NEED A SPEARATE INDICATOR FOR THE RAISED HAND THING
        if (changedDetector.Equals("invisible_hand_raise"))
        {
            if (detector_on && !si.handRaised)
            {
                createInvisibleHandIndicatorIndicator(indicator);
                si.handRaised = true;
            }
            else if (!detector_on && si.handRaised)
            {
                removeInvisibleHandIndicatorIndicator(si);
                si.handRaised = false;
            }
            return;
        }

        //Get's the precidence ordering of these detectors
        int precidence_of_changedDetector = precidence[changedDetector.ToLower()];
        int precidence_of_currentDetector = precidence[si.infoBeingDisplayed.ToLower()];

        //string current_detector, new_detector;
        //makes it so that if the new detector has an equal or lower precidence as the one being displayed rn
        //don't change the indicator
        if (precidence_of_changedDetector <= precidence_of_currentDetector)
        {
            return;
        }

        //if the detector is on and we know it has higher precidence, then we know we're gonna switch to it
        if (detector_on)
        {
            si.infoBeingDisplayed = changedDetector;
        }

        //this is to make the code easier to deal with in DataPiece
        si.detectors_on_array[precidence_of_changedDetector] = detector_on;
        switch (changedDetector.ToLower())
        {
        case "critical_struggle":
            if (detector_on)
            {
                indicator.GetComponent <MeshRenderer>().material = (Material)Resources.Load("UI_Resources/Materials/CriticalStruggleIndicator", typeof(Material));
                return;
            }
            break;

        case "idle":
            if (detector_on)
            {
                indicator.GetComponent <MeshRenderer>().material = (Material)Resources.Load("UI_Resources/Materials/IdleIndicator", typeof(Material));
                return;
            }
            break;

        case "system_misuse":
            if (detector_on)
            {
                indicator.GetComponent <MeshRenderer>().material = (Material)Resources.Load("UI_Resources/Materials/SystemMisuseIndicator", typeof(Material));
                return;
            }
            break;

        case "struggle":
            if (detector_on)
            {
                indicator.GetComponent <MeshRenderer>().material = (Material)Resources.Load("UI_Resources/Materials/StruggleIndicator", typeof(Material));
                return;
            }
            break;

        case "student_doing_well":
            if (detector_on)
            {
                indicator.GetComponent <MeshRenderer>().material = (Material)Resources.Load("UI_Resources/Materials/StudentDoingWellIndicator", typeof(Material));
                return;
            }
            break;

        default:
            Debug.LogError("detector did not match an existing detector (detector unknow)");
            break;
        }

        //if none of the cases applied, then the detecotr must be off so we gotta update
        //Destroy(indicator);
        si.stateUpdate(precidence_of_currentDetector);
    }
コード例 #30
0
        public void Read(BinaryReader reader)
        {
            version    = reader.ReadInt32();
            modid      = reader.ReadString();
            byteLength = reader.ReadInt64();
            if (!(SRModLoader.GetMod(modid) is SRMod mod))
            {
                throw new Exception($"Unrecognized mod id: {modid}");
            }
            var saveInfo = SaveRegistry.GetSaveInfo(mod);

            identifiableData.Clear();
            int count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                var e = new IdentifiedData();
                e.Read(reader, saveInfo);
                identifiableData.Add(e);
            }

            extendedData.Clear();
            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                var e = new ExtendedDataTree();
                e.Read(reader);
                extendedData.Add(e);
            }

            if (version >= 1)
            {
                playerData.Read(reader);
                pediaData.Read(reader);
                BinaryUtils.ReadDictionary(reader, customAmmo, (x) => AmmoIdentifier.Read(x), (x) =>
                {
                    var list      = new List <VanillaAmmoData>();
                    int ammoCount = x.ReadInt32();
                    for (int i = 0; i < ammoCount; i++)
                    {
                        if (x.ReadBoolean())
                        {
                            var newData = new VanillaAmmoData();
                            newData.Load(x.BaseStream);
                            list.Add(newData);
                        }
                        else
                        {
                            list.Add(null);
                        }
                    }

                    return(list);
                });
                if (version < 2)
                {
                    return;
                }
                extendedWorldData = (CompoundDataPiece)DataPiece.Deserialize(reader);
                if (version < 3)
                {
                    return;
                }
                worldData.Read(reader);
            }
            else
            {
                identifiableData.Clear(); // with the new enum translator system we need to make sure old id's are gone
            }
        }
コード例 #31
0
 public ValuedSlimeTraitProcessor(string modid, string traitid) : base(modid, traitid)
 {
     DataPiece.GetTypeID(typeof(T));
 }