Git Product home page Git Product logo

dvtime's Introduction

DvTime - Functional Clocks Mod

This mod makes the various clocks around the Valley work.

Pocket Watch Integration Modes

Change how the pocket watch behaves by selecting one of theses modes in the UMM settings menu.
If you have suggestions for how to better integrate this mod with the pocket watch, please message me.

Exclusive

The pocket watch always shows the time all other functions are disabled. This is the default.

AddAfterTime

When clicking while the stopwatch is ticking down, the clock mode will activate.

ReplaceStopwatch

When the watch is not ticking and is set to zero, so that normally the stopwatch would start, the clock activates instead.

None

The clock cannot be activated and the pocket watch behaves like normal, except for should the watch happen to be in clock mode, clicking once will return it to idle.

Commands

The time shown by this mod can be configured by various console commands:

time.source

If called without arguments it will show how time currently progresses
Call with the id of a timesource to set it.
Call with an invalid id to list all availaible sources. Default sources: realtime, playtime.
Other mods may add additional sources for you to use.
realtime and playtime differ in that the real time always progresses while play time only progresses while in game.

time.current

Get/set the current time

time.scale

Get/set a factor for how fast time progresses.
Value x=1 is as fast as real time.
Values x>1 a faster than real time.
Values 0<x<1 are slower than real time.
Value x=0 is stopped time. Values x<0 are time running backwards.

time.reset

Reset the current time source to default values as if you had started a fresh save for it.

Consuming the time from other mods

Add a reference to DvTime.dll to your project.

If DvTime may be a hard dependency of your mod simply use CurrentTime.Time whenever you need the current time

If DvTime should only be a soft dependency of your mod add this class to your mod and use TimeSource.GetCurrentTime()

public static class TimeSource
{
  static TimeSource()
  {
    try
    {
      // separate function to be able to catch dll load exceptions when DvTime is not installed
      DoInitialize();
    }
    catch (Exception ex)
    {
      Debug.Log($"unable to load DvTime: {ex}" );
    }
    
    if (GetCurrentTime is null)
    {
      // Implement some kind of fallback strategy here
      GetCurrentTime = () => DateTime.Now;
    }
  }

  private static void DoInitialize()
  {
    // Get once to trigger dll load
    _ = CurrentTime.Time;
    GetCurrentTime = () => CurrentTime.Time;
  }

  public static Func<DateTime> GetCurrentTime;
}

Adding new sources

Implement the interface RedworkDE.DvTime.ITimeSource.
Add an event handler to RedworkDE.DvTime.TimeUpdater.RegisterTimeSource and in the event handler add your new source to the provided list.
The first item in that list will be used as the default source.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.